Objective C - SplitViewController没有加载Master UINavigationController

时间:2015-02-18 19:03:08

标签: ios objective-c uinavigationcontroller uisplitviewcontroller master-detail

rootController = [[UISplitViewController alloc] init];
rootController.presentsWithGesture = NO;
masterController = [[MasterViewController alloc] init];
[masterController setCdw:cdw];
detailsViewController *detailsController = [[detailsViewController alloc] init];

detailsController.delegate = masterController;
masterController.detailsDelegate = detailsController;

// MASTER CONTROLLER
UINavigationController * master = [[UINavigationController alloc] initWithRootViewController: masterController];

// DETAIL CONTROLLER
UINavigationController * detail = [[UINavigationController alloc] initWithRootViewController: detailsController];

rootViewController.viewControllers = [NSArray arrayWithObjects: master, detail, nil];
rootController.delegate = detailsController;
self.window.rootviewController = rootController;

这是我用来创建主 - 细节分割视图的功能,它在iPad模拟器上运行时效果很好,例如调用主视图的viewDidLoad方法,然后调用详细信息的viewDidLoad方法叫做。到目前为止一切都很好。

问题是当在iPhone上启动时,拆分视图的行为是奇怪的,因为从不调用主视图(从不调用viewDidLoad方法),而是仅加载详细视图。如果我删除了'详细信息'数组中的UINavigationController然后加载主视图,然后由于缺少详细视图而出现预期的问题。但我无法弄清楚为什么iPad模拟器完美运行,iPhone模拟器甚至没有调用主视图......

0 个答案:

没有答案