【发布时间】:2017-01-13 02:17:57
【问题描述】:
我想在横向模式下显示 1 或 2 个 UIViewcontroller,而在纵向模式下显示其他。 为此,我在 AppDelegate 中实现了这个功能。
-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return self.orientation;
}
在 AppDelegate.h 中,方向是:
@property (nonatomic, assign) UIInterfaceOrientationMask orientation;
在我需要横向方向的 UIViewcontroller(s) 中。我把这段代码
-(void)viewWillAppear:(BOOL)animated
{
self.appDelegate.orientation = UIInterfaceOrientationMaskLandscape;
}
和
-(void)viewWillDisappear:(BOOL)animated
{
self.appDelegate.orientation = UIInterfaceOrientationMaskPortrait;
}
但是,当我转到“LandscapeViewController”时,它工作正常,我返回,它工作正常,我再次转到“LandscapeViewController”,它正常,然后当我返回时,supportedInterfaceOrientationsForWindow 方法停止被调用。有什么理由吗?还是我在做一些奇怪的事情?
【问题讨论】:
标签: ios objective-c orientation uiinterfaceorientation