UIImageview moving position on screen from storyboard - ios

I have a storyboard with a UIImageView on it.
When I load the app in the emulator the UIImageView has a different position.
What could be causing this? The only thing I am doing to the UIImageview in the code is making it a subview of another UIImageview.

It is possible that your storyboard is for the iPhone 5 and not for the iPhone 4 screen.
You can turn this off by clicking on the icon at the bottom of the storyboard screen. It's the left icon in the icon group.
Hope that it's the answer on your question

Are you using Autolayout ? If not , then probably your struts and springs of the UIImageView are not set correctly causing the ImageView to change position.

Related

iOS storyboard how to autolayout image in LaunchScreen.storyboard exactly like in usual VC

I want to place an image into the LaunchScreen.storyboard viewController aswell as place the same image into my rootViewController in the normal storyboard. I want both screens look exactly the same.
But the image is not positioned the same if you use the same autolayout constraints. Might this be due to the statusbar at top which does not appear on launchscreen? How do i have to set up an image to look the same in both storyboard viewcontrollers?

UIImageView in storyboard doesn't show image at start

I am writing an iOS app and I am using storyboards. In some screen I have an UIImageView for a banner. I set the image to the UIImageView in the menu in storyboard. (Not code behind)
But the Image isn't shown after the screen is loaded. After a while the image appears.
Why is the image loaded so late? On other screen everything is ok.
best regards
In my opinion, you should set the background image for banner in file LaunchScreen.xib.

Constraint issue with iPad using single storyboard iOS

I am having issues with a specific view on my storyboard. The button and textview don't show in the right place when using the ipad. It works perfect for the iPhone, however. I am using one storyboard for the both of them. (Not one each) Here is a screenshot for what it is showing and the blue rect is for where the textview should be and the red is for where the GPS button, which is visible to the left, should show. Any ideas? I have tried setting and reseting the constraints, but it has had zero effect.
Thanks

Custom UIButton alignment with respect to background image issues in xcode 5 on iPhone 4s and 5 - addition of constraints does not fix the issues

I am having issues with UIButton with background images. When clicking on a button when running the code in simulator and in iPhone 4s and 5, a button seems to be selected even when I press an area outside the button
I have a very simple UI with an image, followed by another image (Login), followed by 3 custom buttons (Facebook, Email and Signup) and an image after that at the very bottom.
Note -
1. I have each button size (width and height) equal to the size of the background image. So if the background image is say 100 by 20, the button would be 100 by 20. Also, I have Autolayout checked and the image to AspectFill the UIButton in the IB.
I have a UIView within the Superview. All the UI elements (images, UIbuttons with background images) are placed in the UIView.
I have constraints on the UIView for width and height, so that it remains the same in iPhone 4s and 5. I also have constraints to ensure that the UIView is horizontally and vertically centered.
Within the view, I have constraints on each UI element's (images and UIbuttons with images) width and height, so that it remains the same in iPhone 4s and 5. I also have constraints on each elements Y location. So, I have a constraint that the first image is X distance from the UIView's top line. Then, I have a constraint that the first button is Y distance from the image on top. Then, I have a constraint that the second button is Z distance from the first button above it. I, then, have a constraint that the bottom-most label is A distance from the bottom line of the UIView. And I have a constraint that the third button is B distance above the bottom-most label. The idea is to ensure that all these elements are in the center of the screen in iPhone 4s and iPhone 5 (since the UIView will move to the center due to the constraints on it and the UI elements within it will move to the center along with it since their constraints are relative to the UIView).
The project supports iOS 6, 6.1 and 7.
I started developing and testing using iPhone 4s. The buttons seemed to be working fine on it. Then I connected iPhone 5 and, on compiling, I found that the buttons' clickable area and the buttons' background image did not overlap anymore. I re-connected iPhone 4s, cleaned the project, built it again and ran it (both on the simulator and on the device) to find that the buttons did not work anymore. On clicking on an area outside the button, the buttons were getting selected. What was also strange was that in some cases, when I touched a button (ie. Facebook), the button below it (i.e. Email) was getting selected.
So, in summary, it worked fine in iPhone 4s. On connected, iPhone 5, it seems that the buttons stopped working properly. On reconnecting iPhone 4s, the buttons no longer functioned properly. I tried removing all the UI elements and restarting the build (in same view controller in the same storyboard), tried creating a brand new view controller in the same storyboard, but with no luck. I have had to start the project all over again to have it function in iPhone 4s. So, to me, it seems that something is corrupting the storyboard, to an extent that it cannot be fixed again!
I have highlighted the UIView in gray for your reference.
Please see the images for reference -
Basic screen with UIView grayed out and no touch
Basic screen with UIView grayed out and trying to click Facebook button -
Basic screen with UIView grayed out and trying to click on the non-clickable image below the Signup button -
Not sure if anyone has faced such problems But, I would love to understand it and fix it now since it is a reoccurring issue and do not want to face it when most of my project is complete as it seems to completely corrupt the storyboard, leaving me to start the project all over again!
Please help.
Did you try calling sizeToFit method on all the buttons?

Images disappear when switching to 3.5 in iOS

I have two images that I am showing in a UIImageView, they both show up fine when they are edited on the extended storyboard and when ran in the 4in simulator. However when I switch the storyboard to the shorter 4 & 4S size the images disappear, the UIImageViews are still there however it will not display the images. The first picture is of the 4in storyboard and the second is of the 3.5in, all I did was click the resize button at the bottom of the editor to shrink it.
This sounds like a simple layout issue in IB. If you have Autolayout disabled then you need to set some struts for each of the images so that they reposition when the screen size changes. On the right side of IB in Utilities open the Size Inspector panel and set up the Autosizing as in the image below.
Notice only one strut is red, this keeps the content pinned to the bottom.

Resources