joh*_*ers 12 iphone objective-c uiviewcontroller uikit ios
任何人都可以确认,为了支持iOS 6和iOS 5,没有必要添加新的iOS 6自动旋转方法,因为如果您还在实施iOS 5方法,那么Apple文档会建议完全忽略这些方法吗?
特别是,我谈论的方法- (NSUInteger)supportedInterfaceOrientations和- (BOOL) shouldAutorotate- 如果你也实现了这些方法被编译器忽略和合成- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
如果要在新的sdk中打包应用程序,则需要为自动旋转添加新的回调.但是,只有在iOS 6设备上运行此类应用程序时才会收到这些回调.对于在早期iOS版本上运行的设备,将收到早期的回调.如果你没有实现新的回调,默认行为是你的应用程序在iPad上的所有方向上运行,除了iPhone上的UpsideDown方向以外的所有方向.
对于iOS5旋转.检查所需的方向并返回YES
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ((interfaceOrientation==UIInterfaceOrientationPortrait)||(interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)) {
return YES;
}
else return NO;
}
Run Code Online (Sandbox Code Playgroud)
iOS 6.0自动旋转支持
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationIsPortrait(UIInterfaceOrientationMaskPortrait|| UIInterfaceOrientationMaskPortraitUpsideDown);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationIsPortrait(UIInterfaceOrientationPortrait|| UIInterfaceOrientationPortraitUpsideDown);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12681 次 |
| 最近记录: |