如:iPhone手机 Music在纵向模式和横向模式显显示播放列表方式的差异
1.创建Simple View Application一个项目
然后在添加一个UIView 标签设置为 landscape view.而默认的view设置为portrait view
把新加的view 托放到和View Controller同一级
2.然后编辑portrait View 在里面设置布局和样式,设置后把portrait View 托到View Controller 同一级, 把landscape View拖放到View Controller下。开始编辑landscape View
3.编辑成功后, 可以设置该两个view里面公共的属性和方法
4.在ViewController里面设置两个视图进行切换。如:
//首先在ViewController.m里面加入常量定义 #define CRotate (3.1415926/180.0) //改方法在切换屏幕时, 进行调用 -(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { self.view = landscapeView; self.view.transform = CGAffineTransformMakeRotation(CRotate*90); self.view.bounds = CGRectMake(0, 0, 480, 300); }else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { self.view = landscapeView; self.view.transform = CGAffineTransformMakeRotation(CRotate*(-90)); self.view.bounds = CGRectMake(0, 0, 480, 300); }else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) { self.view = portraitView; self.view.transform = CGAffineTransformMakeRotation(0); self.view.bounds = CGRectMake(0, 0, 320, 460); } }