-1

我正在为 iphone4 和 5 开发应用程序。当我使用 shouldAutoRotation 时,它仅支持 iphone4。当我使用 willAnimateRotationToInterfaceOrientation 时,它仅支持 iphone5。我对 iphone4 和 5 都使用了这两种方法,它工作正常。我打算将我的应用程序发布到 appStore。我收到了一些警告,但会完美运行。苹果拒绝应用程序获取警告。

代码:

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

1 回答 1

0

你可能错过了用“}”关闭这个方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

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


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

             //My code here

        }

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

与 willAnimateRotationToInterfaceOrientation 方法相同...

于 2013-04-10T08:40:26.607 回答