【问题标题】:Monotouch Storyboard with with xib-less view controllers带有无 xib 视图控制器的 Monotouch Storyboard
【发布时间】:2012-04-09 06:38:34
【问题描述】:

我目前有一个 monotouch 项目,它使用 Storyboard 和一些无 xib(在 Storyboard 中没有相应 xib 或引用的 ViewController)控制器(例如 Monotouch.Dialog)的组合。

从 Storyboard ViewControllers 调用到 xib-less 的一切都很好。我遇到的问题是,当我需要从无 xib 的 ViewController 调用回 Storyboard ViewController 时。

示例流程:

  • 故事板
    • TabViewController
      • FirstViewController DialogViewController(不在 Storyboard/xib-less 中)
        • 另一个视图控制器

问题是在加载另一个视图控制器时,例如。

var avc = new AnotherViewController();
avc.Person = person
_dvc.ActivateController(avc);

我不得不在 AnotherViewController 上创建一个空的构造函数来实现这一点。然后加载这个视图,但它只是一个空的 UIViewController(不是我的故事板中的那个)。我无法在 MT.Dialog 与 Interface Builder 中的 AnotherViewController 之间设置 Segue,因为 DialogViewController 是通过编程方式创建的。

解决方法 atm 是完全忘记 Storyboard 中的 AnotherViewController 并仅以编程方式创建它 - 但我无法将 Storyboard 视图与编程视图结合/混合,这真是太遗憾了。

任何提示(或 monotouch C# sn-ps)将不胜感激!

【问题讨论】:

  • 不确定我的理解是否正确:你想从一个编程设计的视图控制器中弹出你的AnotherViewController - 它是在你的故事板中使用 IB 设计的 - 对吧?

标签: ios xamarin.ios storyboard xib


【解决方案1】:

您可以从Storyboard 创建一个控制器,只需将identifier 添加到它(在情节提要中),然后执行:

YourController *c = 
[storyboard instantiateViewControllerWithIdentifier:@"YourIdentifier"];

不要忘记在viewDidLoad 中初始化您的实例,因为永远不会调用initWithNibName

【讨论】:

    猜你喜欢
    • 2012-01-21
    • 1970-01-01
    • 2014-10-10
    • 1970-01-01
    • 2011-12-27
    • 1970-01-01
    • 2017-11-14
    • 1970-01-01
    • 2011-02-19
    相关资源
    最近更新 更多