How to fix objects (text fields, labels, etc) in viewcontroller.xib (Xcode 4) - iphone

Sorry I am just learning how to program so sorry for the noob question. I began playing around with Xcode and put together my first test app with just a login and password. The problem I am having is that what is shown in the ViewController.xib screen looks perfectly fine as far as layout. The objects are exactly where I want them to be. However, when I run the simulator, the textfields and labels move around! How can I get it so that exactly what is shown on the ViewController.xib comes up in the simulator? Thanks!
Here is what it looks like from my ViewController.xib screen:
http://i.imgur.com/t9t8oAV.png
And here is what outputs in the simulator:
http://i.imgur.com/2u3FIMN.png

It's caused by autolayout. If you don't want to learn about it (yet), click on a view in interface builder and in right side panel under first tab uncheck "Use autolayout".

Related

Storyboard view designed properly with Auto Layout and Trait Variations in Interface Builder of Xcode 8 has wrong size in Simulator and Device

I've been working on iOS apps for many years before a longer pause. On my new project I decided to try the new features of the Interface Builder and Storyboards (Swift 3, Xcode 8.2.1). So I've got a working app with precisely defined constraints for all supported devices, following the "regular" and "compact" width/height paradigm. Everything seemed to work and I loved the approach.
I was finalising the first views (and their controllers) for the iPad simulator before I decided to run the app also on an iPhone simulator to check for the layout. It turns out that all works as expected but for ONE view.
This view has the following behaviour:
If in the Storyboard canvas (and even the Assistance Editor, which
looks the same for me, by the way) I selected "view as iPad 9,7" and
run the iPad simulator (of the same screen size), the layout works the way it should.
If in the Storyboard canvas I selected "view as iPhone 5" and
run the iPhone 5 simulator, the layout works the way it should.
If however I select "view as iPhone 5" and run the app on the iPad simulator OR any other false combination, the following happens:
Once the view appears (custom segue, or default push. All the views are inside a navigation controller) it shows the content scaled down/up to the size of the preview size I selected on the Storyboard. Then it animates (scaling from the top left corner) to fill the screen. For instance: If I select "view as iPhone 5" and run on an iPad, the view appears in the left top corner of the iPad simulator having the size of an iPhone 5. Then it scales up to fill the screen having the exact layout I want.
One should add that inside this one view, the layout for all devices looks the same, merely scaled down/up. So it really just comes down to wrong view size.
This all happens ONLY to one of my views, which I all have designed and laid out (constraints) the same way. This happens EVERY TIME, and it happens on the simulator and on real devices.
I was trying various suggestions from the web for the last week and I failed to find any topic (on Stack Overflow) that was able to help me.
I'm lost. I'm glad for any suggestions!
Thank you.
After removing everything from my view step by step and building every single step I found that I had a self.view.layoutIfNeeded() inside my viewDidLoad() which was inside an animation block animating a single subview, but for some reason lead to aforementioned issues. Removing it solved the issue.

Inconsistent view in simulator vs device

I am making an app of a calculator and I put a lot of buttons to the main view. However, when I test it on a simulator, some of the buttons don't show up correctly. Can anyone tell me what happens? I'm totally confused because I just drag buttons, labels, etc. from the toolbox in the right of the XCode and changed their fonts and aligned them to role and columns. I didn't do any programming things to buttons (except for adding IBActions and Outlets). Here is a snapshot of my problem.
By the way, the colored rectangles are just textfields to store expressions and answers. They will be transparent finally and are currently colored to show positions on the screen for convenience.
I can't give more details because I don't know anything about any possible reasons. After all, designing the view is just a drawing and aesthetic issue but I am stuck now. Can anyone give an explanation?
So it turns out that I need to disable autolayout. With autolayout, I guess that XCode will optimize with autolayout option on. After turning it off, everything looks good.

Weird iPhone 4 simulator behavior - UITextViews stacked on top of each other

I just finished up my storyboard based iPhone app (I'm developing on an iPhone 5). Just before submitting it to the Appstore, I thought of making sure everything looks fine on an iPhone 4. So I launch my app in the simulator with iPhone 4.
And what I see baffles me. Basically every single view object, particularly textview, are stacked on top of each other. Basically everything scrollable's messed up. In some textviews even, the initial scroll position has been set to say 100px, which means that the textview's showing the middle of the content in a textview and there'sno way to scroll to top.
Every time I make an ajustments to the storyboard view to fit the iPhone 4, the view on iPhone 5 instead looks weird. Most of the time, the stacked objects on iPhone 4 simulator can't even be unstacked.
Am I the only one experiencing this? I cant find any post about it. Could it be that there's something messed up with my simulator? Any setting I've missed? The only solution I can think of now is to have a seperate SB for iP4 and iP5, but I really would rather not go through the pain of doing that. Any comment or idea is greatly appreciated.
How it looks
You need to make sure that your autosizing struts and springs are set appropriately.
The views need to either dock to the top, or bottom and the views that you want to stretch should have the flexible vertical set.

Not all custom button photos are showing up in Xcode simulator or device

I have been working on making home screen button link images for my app to take the user to different pages. When I was finally done with making all of the custom photos (all same resolution), only two of them show up on my device/simulator and I can not for the life of me figure out why. You can view what the storyboard vs the simulator looks like here. It looks the exact same on my iPhone 4, and I adjusted all of the view controllers in my storyboard to be compatible with retina 3.5 inch only. If anyone knows whats going on, I would be more than happy to hear your feedback. Thank you.
1)just strech more that means just try to increase the width & height of your images just by pulling or streching them.
2)be sure images has correct Named
3)be sure that images are added in project

First iPhone App View Position Problem

I am closely following the instructions given in the tutorial "Your First iPhone Application" on apple ADC.
In the interface builder, I have set up a button positioned on the top according to the Apple Interface Guidelines. It runs without trouble if I simulate the interface in IB. However, if I run the built app, I get what is shown here.
If you look at the view clearly, you will see that the entire view has been shifted up. And the magnitude of the shift is exactly the height of the status bar. And that's why the there is blank space at the bottom of the window, which was white instead of red.
I have tried turning on the "Simulated Interface Elements", but that doesn't work either.
The problem persists on real devices as well.
However, using the "Simulate Interface" from IB looks fine.
Any help is appreciated.
Yun Tao
Are you setting the frame of your view?