ios6 rotation problems

2019-09-04 04:59发布

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

4条回答
Rolldiameter
2楼-- · 2019-09-04 05:09

- (BOOL) shouldAutorotate -(NSUInteger)supportedInterfaceOrientations

These are the new functions added to iOS 6.

查看更多
别忘想泡老子
3楼-- · 2019-09-04 05:17
- (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.

查看更多
Viruses.
4楼-- · 2019-09-04 05:31
 -(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.

查看更多
走好不送
5楼-- · 2019-09-04 05:34

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.

查看更多
登录 后发表回答