如何制作iPhone和iPad版的应用程序? [英] How to make iPhone and iPad version of an app?

查看:117
本文介绍了如何制作iPhone和iPad版的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作适用于iPhone和iPad的应用程序。我正在寻找如何使两者兼容的接口。当应用程序加载时,我正在显示表格视图。如何根据设备加载不同的笔尖?我正在使用它在nib之间切换。

I am trying to make an app which works on both iPhone and iPad. I am looking how to make an interface compatible on both. When the app loads I am displaying a table view. How can I load different nibs based on device? I am using this to switch between nibs.

if ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)]) 
    {
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) 
        {
            device = @"iPad";
        }
        else 
        {
            device = @"iPhone";
        }

    }

但在MainWindow.xib中它说视图从iPhone的视图控制器加载。我可以根据设备制作这种动态吗?即我想从应用程序的开始显示基于设备的不同笔尖。
谢谢。

But in MainWindow.xib it says view is loaded from the view controller for iPhone. Can I make this dynamic based on device? ie I want to show from the start of app different nibs based on device. Thanks.

推荐答案

实际上,Apple会自动执行所有操作,只需命名您的NIB文件:

Actually, Apple does all this automatically, just name your NIB files:

MyViewController~iphone.xib // iPhone
MyViewController~ipad.xib // iPad

并使用最少量的代码加载视图控制器:

and load your view controller with the smallest amount of code:

[[MyViewController alloc] initWithNibName:nil bundle:nil]; // Apple will take care of everything

这篇关于如何制作iPhone和iPad版的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆