我正在更新我的 iPad 应用程序,我在拆分视图控制器的表中有一个选项列表,但它没有触发 setDetalItem 没有触发。由于外形尺寸(屏幕太小),这不会移植到 iPhone 上。
从 appDelegate 类:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
UINavigationController *masterNavigationController = splitViewController.viewControllers[0];
JSLMasterViewController *controller = (JSLMasterViewController *)masterNavigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
return YES;
}
从主视图控制器:
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
JSLDetailViewController *detailView = self.detailViewController;
detailView.telegram = indexPath.row;
NSLog(@"Did Fire 1");
}
从我的 detailViewController 中:
- (void)setDetailItem:(id)newDetailItem
{
NSLog(@"Did Fire 2");
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
[self configureView];
}
if (self.masterPopoverController != nil) {
[self.masterPopoverController dismissPopoverAnimated:YES];
}
}
- (void)configureView
{
// Update the user interface for the detail item.
if (self.detailItem) {
//self.detailDescriptionLabel.text = [[self.detailItem valueForKey:@"timeStamp"] description];
NSArray *mainQuestion = [self mainQuestionArray];
NSArray *subQuestion = [self subQuestionArray];
questionTitle.text = mainQuestion[telegram];
subQuestionOne.text = subQuestion[telegram][0];
subQuestionTwo.text = subQuestion[telegram][1];
}
}
我知道我可能需要在 appDelegate 中创建 detailViewController 的实例,但我不确定如何执行此操作。我发现的大多数教程都是从头开始构建拆分视图,或者似乎使用的是旧版本的机制。您能给我的任何提示将不胜感激!