【发布时间】:2011-07-16 03:25:13
【问题描述】:
我想为横向模式使用与纵向模式不同的 UIView,这可能吗?如果可以,我该怎么做?
【问题讨论】:
标签: objective-c xcode ipad uiview orientation
我想为横向模式使用与纵向模式不同的 UIView,这可能吗?如果可以,我该怎么做?
【问题讨论】:
标签: objective-c xcode ipad uiview orientation
在 .h 文件中取一个全局变量“currentOrientationView”。 当您的设备要从任何界面方向旋转时,它会调用“WillRotateToInterfaceOrientation:”,此方法有一个参数告诉设备将要旋转的界面方向,因此将您的条件放入此方法并设置值"currentOrientationView" 对应的视图为:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
currentOrientationView=potraitView;
}else {
currentOrientationView=landscapeView;;
}}
【讨论】:
你必须使用方法 shouldAutorotate 来调整界面方向, 在这个方法里面你必须把代码像
[self.addSubview:newView];
【讨论】:
使用 willRotateToInterfaceOrientation 交换意见。对于您想要支持的所有方向,shouldAutorotateToInterfaceOrientation 应该返回 YES。
【讨论】: