iphone4& amp;的自动旋转iphone 5

时间:2013-04-10 08:30:53

标签: iphone objective-c ios5 ios6 autorotate

我正在开发适用于iphone4和iphone的应用程序5.当我使用shouldAutoRotation时,它仅支持iphone4。当我使用willAnimateRotationToInterfaceOrientation时,它仅支持iphone5。我使用iphone4& 5的两种方法,它工作。我要将我的应用程序发布到appStore。我得到了一些警告,但会完美地运作。 Apple拒绝接受警告的应用程序。

代码:

 - (BOOL)shouldAutorotate
    {
        //returns true if want to allow orientation change
        return TRUE;


    }
    - (NSUInteger)supportedInterfaceOrientations
    {
        //decide number of origination tob supported by Viewcontroller.
        return UIInterfaceOrientationMaskAll;


    }

    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        //from here you Should try to Preferred orientation for ViewController

        return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationPortrait;
    }

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)  interfaceOrientation duration:(NSTimeInterval)duration
{

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {



        if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){

//My code here


    }

}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {


        if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){

//My code here

    }
return YES;
}

1 个答案:

答案 0 :(得分:0)

你可能错过了以“}”这个方法结束

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {


        if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){

             //My code here

        }

    return YES;
    }
  // add:
  return YES;
}

和willAnimateRotationToInterfaceOrientation方法相同......