UILabels and other items added in IB are misplaced when running the application


I load the InfoViewController view as a subview in MainViewController like this (declared in .h):

 - (void)viewDidLoad { [super viewDidLoad]; infoViewController = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:nil]; mainInfoView = (MainInfoView *)[mainInfoViewController view]; } 

(MainViewController is presented by push from a suite from a tableviewcontroller cell and has a navigation bar).

This is in the InfoViewController view to set the view size:

 - (void)viewDidLoad { [super viewDidLoad]; self.view.frame = CGRectMake(130, 0, 178, 299); } 

In the Size inspector for InfoViewController, I configured the same size (with: 178, height: 299).
I disabled "Use Autolayout" for both InfoViewController in XIB and for MainViewController in Storyboard.

I have some UILabels, UITextViews, and UIImageViews in InfoViewController . They are declared with properties in .h and synthesized in .m. and connected to the elements of the XIB. Their contents are defined in viewWillAppear of MainViewController like this:

 - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; infoViewController.kategoriLabel.text = [[objArr objectAtIndex:detailIndex] objectForKey:@"Type"]; } 

When I run the application and this view is entered, some of the tags, images, and textViews are suddenly placed in what appears to be random placements. It only happens to certain elements.

I did this same thing in another application and it works well on the simulator (iPhone 4 ver 6.0) and on the iPhone 5, but in this application it just gets messy for both.
I can not find something different elsewhere in Utilities or elsewhere when I compare applications.

If you have experienced something similar and have solved it or if you could know what might cause it, I will appreciate your answer. Thank you.

PS. I use Xcode 4.5.1

The answer

I had a different problem, but my brute force resolution might also work for you. In my case, I wanted to disable the navigation bar on the final element in a series of view controllers. IB, however, will not allow you to remove the navigation bar, so I had to do it manually in ViewWillAppear. However, once the bar was hidden, IOS moved all my buttons and objects that had been set in IB to the height of the navigation bar (now hidden).

I have resorted to the following in the Controller's view. (objects tend to move visibly when I tried this in WillAppear view)

 -(void) viewWillAppear:(BOOL)animated { //turn off nav bar [[self navigationController]setNavigationBarHidden:YES animated:NO]; //correct positions of items that shift when the bar disappears myThing.center = CGPointMake(desired_x_coord, desired_y_coord); myOtherThing.center = CGPointMake(desired_x_coord2, desired_y_coord2); ...etc... //don't forget to call the base class [super viewWillAppear:animated]; } 

Bad, but worked. If you can not find the source of your moving objects, you can try to force their positions by using viewWillAppear.