Iphone ipad应用程序不适用于横向模式
iPad在纵向上运行良好,但在横向上不起作用 我使用这个代码Iphone ipad应用程序不适用于横向模式,iphone,objective-c,cocoa-touch,ios4,landscape-portrait,Iphone,Objective C,Cocoa Touch,Ios4,Landscape Portrait,iPad在纵向上运行良好,但在横向上不起作用 我使用这个代码 - (BOOL) isPad{ #ifdef UI_USER_INTERFACE_IDIOM return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad); #else return NO; #endif } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)i
- (BOOL) isPad{
#ifdef UI_USER_INTERFACE_IDIOM
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#else
return NO;
#endif
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([self isPad]) {
return YES;
}
else
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
}
- (BOOL)isPadLandscape
{
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
&& (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight
|| self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft));
}
- (BOOL)isPadPortrait
{
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
&& (self.interfaceOrientation == UIInterfaceOrientationPortrait
|| self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown));
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if ([self isPadPortrait])
{
[imageView setFrame:CGRectMake(0, -50, 768, 1024)];
}
else if ([self isPadLandscape])
{
[imageView setFrame:CGRectMake(0, 0, 1024, 768)];
}
}
我尝试在调试期间调用-(BOOL)isPadLandscape方法,但该方法不调用
可能有什么问题?不要忘记在Info.plist文件中为适当的支持位置设置属性
支持的界面方向(iPad)
或者试试这个:
- (BOOL) isPad{
return [[UIDevice currentDevice].model hasPrefix:@"iPad"];
}
如果它是一个iPad应用程序,那么为什么标题中有“iPhone”?你应该确保你所输入的内容真正有意义。始终确保仅在标记字段中指定标记,除非将其放在标题中确实有意义。尝试用我的方法替换方法
isPad
。我使用了你的方法,该方法调用很好,但当我当时执行应用程序横向模式时-(BOOL)ispadclash可能会被调用,但该方法不会被调用。