主窗口应该自动旋转到界面方向
在我的 mainWindow.xib 中,我有这个设置。
1) UINavigationController 包含多个viewController。
2) UIViewController 包含一个带有多个按钮的滚动视图。
我已经在 Appdelegate.h 中定义了它们以获取控件并将它们附加到窗口
[window addSubview:navigationController.view]; // navigationController
[window addSubview:container.view]; //scrollview
[window makeKeyAndVisible];
现在我对 InterfaceOrientation 使用相同的标准代码(在 AppDelegate 和其中的所有后续 viewController 中)。NavigationController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation==UIInterfaceOrientationPortrait ||interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) ? YES : NO;
}
及其后续 viewController 按预期旋转但滚动视图的位置是固定的。
我如何旋转带有按钮的container.view,即滚动条以及navigationController,无论是使用任何If 语句还是为滚动视图定义单独的类。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望在主窗口中发生方向更改事件,您也可以在应用程序委托检查中使用以下方法
setAutoresizingMask: 方法和关联的调整大小蒙版。
If you want orientation change event in mainwindow you can use below method in app delegate
check also setAutoresizingMask: method and the associated resizing masks.