开发者

Device orientation with UINavigationController

I am updating an App who need only 2 Views with the function shouldAutorotateToInterfaceOrientation portrait to landscape view. The project is using UINavigationController so if I want the rotation working to portrait to landscape I had to implement all classes (16 in total) with this code:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return YES;
}开发者_运维技巧

So now the rotation is working but for all views only !! If I put this code only on classes where i need is not working at all.

How I can have the rotation working only for two views ?


If you don't want to do it for every controller, it is better to have those two view controllers observe UIDeviceOrientationDidChangeNotification generated by the UIDevice object. Based on the notifications you can deal with rotating and laying out the subviews.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜