【发布时间】:2011-11-11 22:07:04
【问题描述】:
我正在为我的应用程序使用标签栏控制器。如果我在一个名为“结果”的视图控制器中并且 ios 设备旋转到横向模式,它会切换到我创建的另一个视图,称为landScape。这已经在方法中完成了
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
self.view=landScape;
} else {
self.view=originalView;
}
}
只要我在选项卡栏中的特定控制器(示例结果视图控制器)中,它就可以正常工作。然而;如果我转到标签栏控制器中的另一个元素并且我的手机在横向模式下倾斜,然后我决定转到 resultsviewcontroller,它不会调用我的视图 landScape,而是尝试自行自动调整视图大小并且看起来可怕。我应该在 viewDidLoad 方法中调用方法 -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 来解决问题吗?或者这是完全错误的?
提前谢谢你!
【问题讨论】:
标签: objective-c ios xcode views