开发者

iPad landscape orientation height/width issue

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, 7开发者_StackOverflow68 I also set my view controllers only to return landscape left:

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


Instead of setting up subviews in -init, set them up in -loadView (if you aren't using a xib) or -viewDidLoad (if you are using a xib). When those methods get called, your UIViewController should be in the correct state and work as you want it to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜