开发者

mainwindow shouldAutoRotateToInterfaceOrientation

In my mainWindow.xib, I have this setup.

1) UINavigationController containing several viewControllers.

2) UIViewController containing a scrollview holding several buttons.

I've defined them in Appdelegate.h to get the control and attached them to window

[window addSubview:navigationController.view];      // navigationController
[window addSubview:container.view];                 //scrollview
[window makeKeyAndVisible];

Now I'm using the same standard code for InterfaceOrientation (In the AppDelegate and in all subsequent viewControllers in it.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

return (interfaceOrientation==UIInterfaceOrientationPortrait ||interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) ? YES : NO;

}

The NavigationController and its subsequent viewControllers rotates as expected but the scrollview doesn't. Its position is fixed.

How can I rotate the container.view i.e scrollbar with buttons along with the navigationController whether using any If statement or 开发者_如何学运维defining a separate class for the scrollview.


If you want orientation change event in mainwindow you can use below method in app delegate

- (void)application:(UIApplication *)application willChangeStatusBarOrientation:(UIInterfaceOrientation)newStatusBarOrientation duration:(NSTimeInterval)duration

check also setAutoresizingMask: method and the associated resizing masks.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜