2013-07-09 68 views
0

我已经看过几个例子,但我还没有能够让事情正常工作。我在一个普通应用程序的大型代码库中。我带一个的.xib像这样:在主视图设计中仅引入.xib详细视图

TestView *newView = 
[[TestView alloc] init]; 

[self presentViewController:newView animated:YES completion:nil]; 

用于加载的.xib对事物的iPhone端得很好,但在iPad的SIM卡覆盖的.xib整个屏幕。我怎样才能使它只覆盖细节视图?据我所知,在它的appdelegate提出两项视图控制器(即splitviewcontroller),但我别无选择,做这样的事情

[detailViewController presentViewController:newView animated:YES completion:nil]; 

回答

0

你必须创建在AppDelegate的一个UISplitViewController的一个实例。 UISplitViewController只能在iPad上使用,因此您必须将其放入if语句中。

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
    UIViewController *master = [self buildMaster]; 
    UIViewController *detail = [self buildDetail]; 
    UISplitViewController *splitViewController = [[UISplitViewController alloc] init]; 
    splitViewController.viewControllers = @[master, detail]; 
    [self.window setRootViewController:splitViewController]; 
} 
相关问题