ios6旋转问题
我正在将我的应用程序转换为ios6,但我遇到了旋转问题。 有人能帮助我在旋转设备时调用哪些方法吗ios6旋转问题,ios6,screen-rotation,Ios6,Screen Rotation,我正在将我的应用程序转换为ios6,但我遇到了旋转问题。 有人能帮助我在旋转设备时调用哪些方法吗 -(NSInteger)支持接口方向 这些是iOS 6新增的功能 -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } -(void)viewWillLayoutSubviews { if([self interfaceOrientation] == UIInterfa
-(NSInteger)支持接口方向
这些是iOS 6新增的功能
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
-(void)viewWillLayoutSubviews
{
if([self interfaceOrientation] == UIInterfaceOrientationPortrait||[self interfaceOrientation] ==UIInterfaceOrientationPortraitUpsideDown)
{
//set the frames here
}
else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight)
{
//set the frames here
}
}
最好这样做,每次更改设备的方向时,都会调用上述方法
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self doLayoutForOrientation:toInterfaceOrientation];
}
- (void)doLayoutForOrientation:(UIInterfaceOrientation)orientation {
if (UIInterfaceOrientationIsPortrait(orientation))
{
//set the frames here
}
else
{
//set the frames here
}
}
这些是ios 6中的新方法,您可以根据方向设置帧。希望它对您有用。用这些方法处理旋转
-(BOOL) shouldAutorotate
{
return NO;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
如果某个视图在旋转中,而您不需要,例如UIImagePickerController,只需创建一个子类并重写第一个方法。您是否使用了任何第三方UI框架,如three20或其他什么?如果不查看页面代码,我将无法回答您的问题,因为旋转无法正常工作。