Dro*_*bag 18 iphone xcode uiviewcontroller screen-orientation ipad
我一直在以纵向模式编写我的Universal应用程序,现在在大约15个nib文件,许多viewCotnrollers之后,我想实现shouldAutorotateToInterfaceOrientation并在Landscape模式下设计一些屏幕.
添加:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
Run Code Online (Sandbox Code Playgroud)
对我的所有viewControllers,都不做这项工作.
在调试期间,我看到这个方法被调用,但它不起作用!不在模拟器中,不在设备中,不在Iphone中,不在Ipad中!
我在论坛中搜索了一些答案,并看到了一些建议:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown );
}
Run Code Online (Sandbox Code Playgroud)
也没用,
添加:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
Run Code Online (Sandbox Code Playgroud)
和
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
Run Code Online (Sandbox Code Playgroud)
到我的viewDidLoad和viewDidUnload也分别没用.
我迷路了...任何帮助都会做!
还有一个信息...我的所有视图都是UIControl类型,因为我需要TuchUpInside才能工作.
赞赏你的帮助.
cdu*_*uhn 44
确保所有父视图都具有autoresizesSubviews = YES.如果您没有在IB中为所有视图设置弹簧和支柱,则可能需要在代码中执行此操作.
引用Interface Builder用户指南:
要点:在Cocoa nib文件中,如果未在Interface Builder中为视图设置任何弹簧或struts,但是然后使用setAutoresizingMask:方法在运行时添加自动调整行为,则视图可能仍未显示正确的自动调整行为.原因是如果这些子节点没有设置弹簧和支柱,Interface Builder将完全禁用父视图的子节点的自动调整大小.若要再次启用自动调整大小行为,必须将YES传递给父视图的setAutoresizesSubviews:方法.执行此操作后,子视图应正确自动调整大小.
还有其他一些需要注意的事项:
如果UINavigationController的根视图控制器也设置为自动旋转,则它只会自动旋转.
如果UITabBarController的所有视图控制器都设置为自动旋转,则它只会自动旋转.
归档时间: |
|
查看次数: |
35773 次 |
最近记录: |