Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This sometimes happens for view controllers like table, tab bar and collection.</p> <p>It's caused, I think, by something in the Objective C base class <code>init</code> referencing the <code>View</code> - and thus triggering <code>ViewDidLoad</code> before the C# construction is fully complete. This is a bit like what can happen in 'pure' c# if a base class constructor references a virtual method.</p> <p>To check this is occurring for your app, put 2 breakpoints in your app - one in the ViewController constructor and one in ViewDidLoad - if ViewDidLoad is fired first, then you know this is the case.</p> <p>The only way around this I've found is to code around this by triggering a second ViewDidLoad call in the constructor.</p> <pre><code> public FirstView() { // need this additional call to ViewDidLoad because UIkit creates the view before the C# hierarchy has been constructed ViewDidLoad(); } public override void ViewDidLoad() { base.ViewDidLoad(); if (ViewModel == null) return; // ... </code></pre> <hr> <p>If it helps:</p> <ul> <li>I believe I've talked about this in at least one N+1 - maybe N=25 - see <a href="https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/blob/master/N-25-Tabbed/Tabbed.Touch/Views/FirstView.cs" rel="nofollow noreferrer">https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/blob/master/N-25-Tabbed/Tabbed.Touch/Views/FirstView.cs</a> and <a href="http://mvvmcross.wordpress.com" rel="nofollow noreferrer">http://mvvmcross.wordpress.com</a></li> <li>The same type of thing happens in pure objective C code - eg see <a href="https://stackoverflow.com/questions/5620990/initialize-uitableviewcontroller-with-super-initwithstyleuitableviewstylegroup">initialize UITableViewController with [super initWithStyle:UITableViewStyleGrouped]</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload