自动旋转iphone4和iphone5
问题描述:
我为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;
}
答
你可能已经错过了缩小与 “}” 这种方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){
//My code here
}
return YES;
}
// add:
return YES;
}
与同为willAnimateRotationToInterfaceOrientation方法...
苹果可能会接受你的应用程序,警告不是错误,但它取决于警告的类型,当然......你可以发布警告吗?添加行作为评论belove每行代码与警告,请... – meronix 2013-04-10 08:34:30
Appstore不会拒绝您的应用程序,但在Objective-C中的警告是重要的,所以尝试'将警告视为错误' – 2013-04-10 08:45:19
shouldAutorotateToInterface已弃用在ios6 ; UITextAlignmentLeft在ios6中已弃用;这是我的警告 – Ram 2013-04-10 08:46:24