如何从纵向旋转到横向?我必须实施什么?我必须怎么做才能让我的视图调整到新的宽度?
问问题
562 次
3 回答
2
下面的方法“return yes”将改变方向,如果它是“return NO”,方向不会改变。
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation
{
return YES;
}
祝一切顺利。
于 2010-06-29T20:08:56.720 回答
0
要回答问题的第二部分,您可以通过覆盖该-willRotateToInterfaceOrientation:duration:
方法添加逻辑来调整视图大小或位置,例如:
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIDeviceOrientationUnknown || toInterfaceOrientation == UIDeviceOrientationFaceUp || toInterfaceOrientation == UIDeviceOrientationFaceDown) {
// do something here for these orientations
}
else {
// do something else for the remaining orientation types
}
}
于 2010-06-29T20:20:32.187 回答
0
如果您的视图控制器不是顶层视图控制器,则必须从顶层视图控制器传递消息willRotateToInterfaceOrientation:duration: ..您的视图控制器可能不会收到该消息...
在我的顶层视图控制器的 willRotateToInterfaceOrientation:duration: 中,我包含了这一行...(frameViewController 是我的第二级视图控制器)
if (frameViewController)
[frameViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
于 2010-08-25T03:59:32.030 回答