首页 文章

iPad模拟器/设备使用iPhone故事板

提问于
浏览
5

所以我已经为iPhone创建了一个应用程序,我希望通过以下步骤将其转换为iPad,这是answer .

  • 复制您的iPhone-Storyboard并将其重命名为MainStoryboard_iPad.storyboard

  • 打开此文件任何文本编辑器 .

  • 搜索targetRuntime =“iOS.CocoaTouch”并将其更改为targetRuntime =“iOS.CocoaTouch.iPad”

  • 现在保存所有内容并重新打开Xcode - > iPad-Storyboard包含与iPhone文件相同的内容但是每一个都可能被排除在外

一切都做得很好,但iPad模拟器/设备无论如何都使用iPhone故事板 . 有什么建议?

我在摘要中设置了iPad故事板 - > ipad部署信息 - >主要故事板 . 并且main.plist->主故事板文件基本名称(iPad)设置为iPad故事板 .

请告诉我我错过了什么 .

UPD . 有趣的是,当我从ipad部署信息中删除iPad故事板名称时,它仍然在设备上使用我的iPhone故事板 .

enter image description here

enter image description here

enter image description here

enter image description here

2 回答

  • 4

    别忘了在项目的info.plist文件中添加以下内容(主要故事板文件基本名称/主要故事板文件基本名称(iPad))

    enter image description here

    希望这可以帮助 .

  • 4

    您总是可以在appDelegate中选择正确的故事板,并以编程方式显示相应的根视图控制器

    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    {
        UIViewController *rvc;
    }
    

    履行

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
           UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"IPAD_Storyboard" bundle:nil];
           rvc = [storyboard instantiateViewControllerWithIdentifier:@"identifierForController"];
        }
        else {
           UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
           rvc = [storyboard instantiateViewControllerWithIdentifier:@"identifierForController"];
        }
    
    
        [self.window addSubview:rvc.view];
        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
    
        return YES;
    }
    

相关问题