【发布时间】:2012-04-19 04:56:59
【问题描述】:
我正在开发一个具有启动画面和主屏幕的应用程序。我的应用程序是横向和纵向模式应用程序。 当我的应用程序启动并且我处于横向模式时,我的主屏幕会显示纵向模式几毫秒,然后进入横向模式。我希望它应该直接以横向模式显示视图。
谢谢
【问题讨论】:
-
有类似的问题,用这个解决了:stackoverflow.com/a/10146270/894671
标签: iphone
我正在开发一个具有启动画面和主屏幕的应用程序。我的应用程序是横向和纵向模式应用程序。 当我的应用程序启动并且我处于横向模式时,我的主屏幕会显示纵向模式几毫秒,然后进入横向模式。我希望它应该直接以横向模式显示视图。
谢谢
【问题讨论】:
标签: iphone
我通常启用通知:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
在我的控制器上我放了:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self configureOrientation:toInterfaceOrientation];
}
- (void)configureOrientation:(UIInterfaceOrientation)orientation
{
if(UIDeviceOrientationIsValidInterfaceOrientation(orientation)){
if(UIInterfaceOrientationIsLandscape(orientation)){
[self configureLandscapelView];
}else if(UIInterfaceOrientationIsPortrait(orientation)){
[self configurePortraitlView];
}
}
}
您还可以从 UIViewController 本身获取方向:
UIInterfaceOrientation orientation = [self interfaceOrientation];
或者从状态栏:
[UIApplication sharedApplication] statusBarOrientation]
【讨论】: