我无法弄清问题是什么,我使用了2个教程和Apple给你的例子,但它仍然不会更新。我正试图解决这个问题4天了 一些信息:我正在为这个项目使用故事板
Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
return YES;
}
MasterViewController.m
为控制器(nieuwViewController)创建了一个属性
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SearchResult *searchResult = [searchResults objectAtIndex:indexPath.row];
NSLog(@"%@",searchResult);
self.nieuwViewController.searchResult =searchResult;
}
NieuwViewController.m
- (void)setSearchResult:(SearchResult *)newSearchResult
{
if (_searchResult != newSearchResult) {
_searchResult = newSearchResult;
// Update the view.
[self updateUI];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"DETAIL VIEWDIDLOAD");
NSLog(@"%@",self.searchResult);
[self updateUI];
}
在updateUI中我设置了所有标签等,但是如果我也记录了它被调用一次(当应用程序启动时)
答案 0 :(得分:0)
viewDidLoad
只在初始化NIB或故事板时调用一次。使用viewWillAppear
更新ui。但请记住,在SplitViewController中,详细信息视图不会自动更新;从didSelectRowAtIndexPath
触发更新。