【问题标题】:IOS SplitViewController detail view's data is empty / not loading, but the view isIOS SplitViewController 详细视图的数据为空/未加载,但视图为
【发布时间】:2013-07-25 03:57:33
【问题描述】:

这可能真的很简单,在那种情况下对不起。

我正在向我的应用程序添加一个 SplitViewController。一切正常,除了在 detailView 中加载的视图;它确实加载(控件等),但数据保持“空白”,就像它没有从数据库中获取数据一样。

但它是,视图本身负责它,当我不将它插入 detailViewController 时它可以工作!

检查一下:

//this is my data and my ViewController
Medication* med = self.medications[indexPath.row]; 
MedicationViewController* viewController = [[MedicationViewController alloc] initWithMedication:med isNew:NO];

//1. this *doesn't work*, the detail panel get replaced, but the data from "med" never appears
self.detailViewController = viewController;

//2. but if I do this, everything works fine.
[self presentViewController:viewController animated:YES completion:nil];

我的猜测是,我的替换 (1.) 做错了。 有没有cmets?我是否缺少“刷新”、“重新加载”功能?

【问题讨论】:

    标签: ios uisplitviewcontroller detailview


    【解决方案1】:

    最后,我这样做了:

    UINavigationController* detailNavController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
    self.splitViewController.viewControllers = @[self.splitViewController.viewControllers[0], detailNavController];
    

    不是只更改一个控制器,而是更改整个数组,但保持对主控制器的相同引用。效果很好!

    【讨论】:

      猜你喜欢
      • 2015-07-23
      • 1970-01-01
      • 2014-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-22
      • 1970-01-01
      相关资源
      最近更新 更多