I have a custom UIView that I use to display synchronization in my device, but it won't rotate with the device when the orientation changes. Everything else rotates just fine, is there something I am missing to ensure my subclassed uiview will rotate?
问问题
721 次
2 回答
1
Programmatically:
- (BOOL)shouldAutorotate{
return YES;
}
add this. Hope this helps..
Or go to your Target Settings and click the directions you want it to rotate, but this will affect all your viewcontrollers.
于 2013-01-19T07:26:06.380 回答
0
您可以按照以下任何一种方法,
1-创建一个类来继承 UIView 并覆盖 .m(实现文件)中的 shouldAutorotate。现在在您的 viewController 中包含这个自定义 UIView 类来创建对象。
2-为 UIView 类创建类别
注意:- 如果您的构建应用程序支持 iOS6,那么不要忘记包含适用于您要求的方法
>>>>>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
>>>>- (BOOL)shouldAutorotate;
>>>>- (NSUInteger)supportedInterfaceOrientations;
>>>>- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
类别示例:-
@interface UIView (Additions)
@end
@implementation UIView (Additions)
- (BOOL)shouldAutorotate{
return YES;
}
@end
于 2013-01-19T09:16:16.537 回答