更换iPhone上的ViewController
我的应用程序只有一个肖像驱动的GUI,但只有一个部分需要旋转。 当设备旋转时,我想关闭当前视图(控制器?),并将其替换为外观完全不同的视图。更换iPhone上的ViewController,iphone,uiviewcontroller,rotation,Iphone,Uiviewcontroller,Rotation,我的应用程序只有一个肖像驱动的GUI,但只有一个部分需要旋转。 当设备旋转时,我想关闭当前视图(控制器?),并将其替换为外观完全不同的视图。 我该怎么办?任何示例代码?您只需在.xib文件中的同一UIViewController中有两个不同的视图,并在需要时在它们之间切换即可 - (void)didRotate { //Create your new view controller here if it doesn't exist. //Push or present the view co
我该怎么办?任何示例代码?您只需在.xib文件中的同一UIViewController中有两个不同的视图,并在需要时在它们之间切换即可
- (void)didRotate
{
//Create your new view controller here if it doesn't exist.
//Push or present the view controller
}
假设UIViewController中有两个视图:
查看肖像
-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
switch (toInterfaceOrientation)
{
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
self.view = self.ViewPortrait;
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
self.view = self.ViewLandscape;
break;
}
}
那么您想加载一个新的viewController吗?