2013-04-10 58 views
-1

我为iPhone4开发应用程序& 5.当我使用shouldAutoRotation它只支持iphone4。当我使用willAnimateRotationToInterfaceOrientation时,它仅支持iphone5。我使用iPhone4的两个方法& 5,它的工作。我要将我的应用发布到appStore。我收到了一些警告,但会完美地工作。苹果拒绝应用程序获取警告。自动旋转iphone4和iphone5

代码:

- (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; 
} 
+0

苹果可能会接受你的应用程序,警告不是错误,但它取决于警告的类型,当然......你可以发布警告吗?添加行作为评论belove每行代码与警告,请... – meronix 2013-04-10 08:34:30

+0

Appstore不会拒绝您的应用程序,但在Objective-C中的警告是重要的,所以尝试'将警告视为错误' – 2013-04-10 08:45:19

+0

shouldAutorotateToInterface已弃用在ios6 ; UITextAlignmentLeft在ios6中已弃用;这是我的警告 – Ram 2013-04-10 08:46:24

回答

0

你可能已经错过了缩小与 “}” 这种方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 

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


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

      //My code here 

     } 

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

与同为willAnimateRotationToInterfaceOrientation方法...

+0

willAnimateRotationToInterfaceOrientation将不需要返回YES;我对么? – Ram 2013-04-10 08:44:01

+0

@Ram不,你错了,每一个返回值的方法必须返回一个值,否则你会得到一个警告 – tkanzakic 2013-04-10 08:48:18

+0

你必须返回一个BOOL(YES或NO,只是你知道默认值应该是什么) – meronix 2013-04-10 08:53:25