我想在横向和纵向模式下运行应用程序,如何检查appdelegate上的横向和纵向模式?
如何在Appdelegate上检查横向和纵向模式?
我打电话
- (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]) {
NSLog(@"is pad method call");
return YES;
}
else
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
}
- (BOOL)isPadPortrait
{
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
&& (self.interfaceOrientation == UIInterfaceOrientationPortrait
|| self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown));
}
- (BOOL)isPadLandscape
{
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
&& (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight
|| self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft));
}
,但给出了类型的appdelegate的对象未找到错误 接口属性定位。
我该怎么做?
@Ankit:这对您有帮助吗? –
这不适用于appDelegate。在我的情况下,无论方向如何,条件始终是LandscapeRight。 – NightCoder