iPad Childviews still see incorrect bounds in landscape mode even in viewDIdAppear

I have created 2 child views inside my view controller to be swapped between each other based on 2 different buttons.

a la, button 1 shows childview1 etc.

However, when I start the app in landscape mode and print out the bounds for the childviews in viewDidAppear, the bounds are still incorrect.

So basically,

  1. In view controller's viewDidAppear method, i create 2 childviews, then i immediately print out bounds here for the viewcontroller. they are correct.

  2. In the childviewcontroller's viewDidAppear method, i also print out the bounds AFTER i know they are correct for the parent and they are still incorrect.

so the output looks like this..

ViewController Bounds Height2:748.000000 Width: 1024.000000   
Child Bounds Height:1004.000000 Width: 768.000000

and when the app loads, my viewcontroller has correct dimensions, and the childs do not.

Any ideas? is there some way to set the childs boundaries on creation?



I think the problem is that you never set your child view controllers' views' frames from anywhere outside of the child view controllers. Within your parent view controller's viewDidLoad method (or the viewDidAppear method, if you like) and after the child view controllers have been initialized, set their frames using the parent view controller's bounds.

For example, you might put the following in your parent view controller's viewDidLoad method:

childViewController.view.frame = CGRectMake(0, 50, self.view.bounds.size.width, self.view.bounds.size.height - 50);

Need Your Help

No data in SQLite

iphone ios sqlite core-data

I have this book about Core Data. I am on my second chapter and there's an ongoing project that I followed. The project adds an Organization, and three employees. One of the employee is a leader. I...

Static maps upgrade cannot add controls and directions

google-maps google-static-maps

In my old google static maps a control appeared giving the user the option to zoom pan etc and display my main address which I had a marker set to view direction search nearby etc.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.