加载不同的Nib文件 [英] Loading the Different Nib Files

查看:84
本文介绍了加载不同的Nib文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为iPhone和iPad创建了两个nib文件,因此我的应用程序将是通用的。

I created two nib files for the iPhone and iPad, so my app will be universal.

我使用此方法检查它是否是iPad:

I use this method to check if it is an iPad:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

但是当我知道它是什么时,我不知道如何加载正确的笔尖。

but I don't know how to load the proper nib when it knows which it is.

有没有人知道正确的方法相应地加载到nib文件?

Does anyone know the correct method to load to nib file, accordingly?

推荐答案

你的界面文件的名称应该不同,所以这样的东西应该可以工作。

Your interface files should be named differently so something like this should work.

UIViewController *someViewController = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    someViewController = [[UIViewController alloc] initWithNibName:@"SomeView_iPad" bundle:nil];
}
else
{
    someViewController = [[UIViewController alloc] initWithNibName:@"SomeView" bundle:nil];
}

这篇关于加载不同的Nib文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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