2

I have an iPad app that's only supposed to run in UIInterfaceOrientationLandscapeLeft. I have set this in my plist, but all UIViewControllers are still allocated with a portrait frame, until they have finished launching. So any subviews I set in -init based on my view controllers' frames are wrong.

I have output self.view.frame and it's 0, 0, 768, 1024 while it should be 0, 0, 1024, 768 I also set my view controllers only to return landscape left:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
4

1 回答 1

0

不要在 -init 中设置子视图,而是在 -loadView(如果您不使用 xib)或 -viewDidLoad(如果您使用 xib)中设置它们。当这些方法被调用时,您的 UIViewController 应该处于正确的状态并按照您的意愿工作。

于 2011-03-13T17:45:19.900 回答