Bug 7529 - Viewcontroller not showing up in ios6
Summary: Viewcontroller not showing up in ios6
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-09-28 10:48 UTC by cliknpop
Modified: 2012-10-01 16:52 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description cliknpop 2012-09-28 10:48:25 UTC
I have a problem with IOS6 where after an async web service call, my view is being pushed onto the view, it hits the constructor, but the willappear event never happens, and the view never shows. It works in 5.1..

Works in 6.0 simulator, and 5.1 devices
Does not work on 6.0 devices

SearchResultsViewController constructor gets called, but the ViewWillAppear never executes.

code:
	SearchResultsViewController resultsView;


	void HandleSearchCompleted (object sender, SearchCompletedEventArgs e)
	{
		try {
			this.InvokeOnMainThread (delegate {
				if (e.Error == null) {
					Console.WriteLine ("Found {0} results", e.Result.Length);

					var resultsData = new SearchResultsDataSource (e.Result);
					resultsView = new SearchResultsViewController (resultsData);
					resultsView.Title = AppData.searchCriteria.Location;

					activityIndicator.StopAnimating ();
					activityIndicator.Hidden = true;

					this.NavigationController.PushViewController (this.resultsView, true);
				} else {
					Console.WriteLine (e.Error.Message);
				}
			}
			);
		} catch {
		}
	}
Comment 1 Sebastien Pouliot 2012-09-28 11:02:48 UTC
We'll need a more complete test case to see what's going on. I have almost identical code that works correctly on iOS 6 devices (simulator and iOS5.1 too).

A bit of a long shot but this _could_ be due to UIViewController's containment [1], since iOS6 is less tolerant than earlier releases, and that can cause some events not to work as expected. If you do some form of containment I suggest you to watch the WWDC videos about this (it's not hard, once you know what to do, but otherwise it's very easy to get it wrong).

[1] http://stackoverflow.com/q/8379759/220643
Comment 2 cliknpop 2012-09-28 13:30:52 UTC
I have another view that works fine with a simple 

this.NavigationController.PushViewController(new MultidateCalendarViewController{Title="Calendar"}, true);

for example... the only difference between the 2, is one has to get data from an async web service call where the 2nd does not, and all that the async method needed was the InvokeOnMainThread function to update the UI.

I am still a bit green on ios development, I did take a class about 2 years ago when XCode was version 3.x, this is my 2nd app, and first in MonoTouch.  From what I understand the methods used in the article posted above, is basically all done in the PushViewController function.  Correct me if I'm wrong here.

I'll review the posted article, and if I come across a solution, I will post it here.
Comment 3 cliknpop 2012-10-01 16:52:31 UTC
I did get this working, and in the end here is what I have.

Moved the async web service call to the "results" view, invoking the web service call from ViewDidAppear.  (Doing this will affect UI design a bit as the table view should be hidden until data loads, activity indicator moved to this screen, etc)  By moving the web service call, the screen appeared, then I found some issues with the local reference for the tableview... see below.

The other issue was with the xib file which contained an extra viewcontroller in the hierarchy causing an UIViewControllerHierarchyInconsistency error, "A view can only be associated with at most one view controller at a time!"

http://stackoverflow.com/questions/12434937/uiviewcontrollerhierarchyinconsistency-when-trying-to-present-a-modal-view-contr

After removing this ViewController, and making sure my "File Owner" class was set to my view controller, all is working as expected on 5.1 and 6.0 devices.