启动应用程序 Iphone 纵向和 Ipad 横向

Posted

技术标签:

【中文标题】启动应用程序 Iphone 纵向和 Ipad 横向【英文标题】:Launch app Iphone portrait, and Ipad landscape 【发布时间】:2013-09-12 21:02:30 【问题描述】:

我有这个代码,我需要检测是 ipad 启动应用程序横向还是 iPhone 在纵向模式下

    NSString *deviceType = [UIDevice currentDevice].model;

    if([deviceType isEqualToString:@"iPhone"])
    
        NSLog(@"This is iPhone");
    
    else
    
        NSLog(@"This is iPad");
    

【问题讨论】:

iPod touch 怎么样?你应该使用if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 【参考方案1】:

这行得通!!! ios 6

-(NSUInteger)supportedInterfaceOrientations

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

        return UIInterfaceOrientationMaskPortrait;
    else
        return UIInterfaceOrientationMaskLandscape;


- (BOOL)shouldAutorotate 
    return YES;

【讨论】:

以上是关于启动应用程序 Iphone 纵向和 Ipad 横向的主要内容,如果未能解决你的问题,请参考以下文章

支持iPhone 6和iPhone 6+,具有不同的启动/启动屏幕图像,适用于iPad纵向和横向方向

我可以为 iPhone 和 iPad(纵向和横向)使用单独的故事板吗?

iPad 总是横向启动

在 iPad 上以横向启动后,iphone 应用程序没有响应

3 个针对 iphone 纵向、横向和 ipad 纵向的媒体查询

Iphone 应用程序在横向和纵向模式下都可以正常工作,但在 ipad 中它只能在一种模式下工作?