ios6 rotation problems

允我心安 提交于 2019-12-25 00:53:11

问题


I am converting my app to ios6 but i am getting rotation problems. Can some one help me which methods will be called when we rotate device


回答1:


- (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
} 
}

These are the new methods in ios 6 where you can set the frames as per the orientation. Hope it will useful to you.




回答2:


- (BOOL) shouldAutorotate -(NSUInteger)supportedInterfaceOrientations

These are the new functions added to iOS 6.




回答3:


 -(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
    }
}

better go with this , the above method will call every time when you change the orientation of the device.




回答4:


Handle the rotation with these methods

-(BOOL) shouldAutorotate
{
    return NO;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

If some-view in rotating and you don't want such as UIImagePickerController just make a child class and override first method.



来源:https://stackoverflow.com/questions/13448192/ios6-rotation-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!