2013-04-10 102 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