0

我正在尝试使用

但对于通用应用程序

我得写。。

if([[UIDevice current]UserInterfaceIdiom] == UIUserInterFaceIPad)
{
    MyViewController *controller = [[MYViewController alloc]initWithNibName:@"MyViewController_IPad"];


    [self.navigationCOntroller pushViewController:myViewController animated:YES];

    else{
    MyViewController *controller = [[MYViewController alloc]initWithNibName:@"MyViewController_IPhone"];


    [self.navigationCOntroller pushViewController:myViewController animated:YES];

}

我可以得到解决方案来克服“if”条件并避免设备检查..

4

1 回答 1

2

制作两个笔尖,一个用于 iPhone,一个用于 iPad,MyViewController~iphone.xib并命名它们MyViewController~ipad.xib(注意:匹配外壳很重要!)。确保将它们都添加到您的目标中,然后在您的代码中执行以下操作:

MyViewController *controller = [[MYViewController alloc]initWithNibName:@"MyViewController"];
[self.navigationCOntroller pushViewController:myViewController animated:YES];
于 2012-09-12T13:18:00.247 回答