首页 > 解决方案 > UI Components not instantiating on Xamarin.IoS on Visual Studio for Mac Community when added from designer

问题描述

As the title says, I'm trying to add a new component in my storyboard and it works fine, but after giving it a name and heading to my controller class code behind to work with it, it always comes back as null on runtime.

I am using visual studio for mac community version 8.2.6(build 26).

Steps followed:

  1. Add new storyboard
  2. Add a table view controller and assign the controller class on widget properties
  3. Add a picker to the table view controller and assign it a name
  4. Call added picker and assign a the corresponding Model overriding ViewDidLoad()
  5. Run the project

Once the program reaches step #4 and tries to assign the Model. The picker always comes as null. The same happens if I add a label or any other element, once it reaches ViewDidLoad() or any other of the life cycle methods it remains null.

I've tried cleaning, rebuilding, restaring vs, restaring the mac but none of those worked

标签: c#xamarin.ios

解决方案


解决了。

从使用“storyboard.InstantiateInitialViewController()”到“storyboard.InstantiateViewController(controllerId)”,由于某种原因,它正确初始化了所有组件。


推荐阅读