【问题标题】:Why is my iPad app not detecting orientation change?为什么我的 iPad 应用程序没有检测到方向变化?
【发布时间】:2012-01-25 16:25:09
【问题描述】:
使用以下代码没有给我任何东西...我的视图旋转。看不懂……
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
NSLog(@"I am starting to rotate");
}
谢谢...
【问题讨论】:
标签:
objective-c
ios
ipad
orientation
【解决方案1】:
这可能是由于您的 VC 嵌套在 VC 的层次结构中的方式。
This SO 帖子应该可以帮到你:
【解决方案2】:
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if(self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
self.interfaceOrientation == UIInterfaceOrientationLandscapeRight){
NSLog(@"I am starting to rotate in Landscape");
} else {
NSLog(@"I am starting to rotate in Portrait");
}
}
并保持原样
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}