4109

UISplitViewController is not rotating correctly

Question:

I know there is a lot of discussion on this topic on stack overflow, but none of the questions have an answer that works for me.

I have a SplitViewController that loads as the root view controller, and both of the tableviews inside the SVC have ShouldAutoRotate set to return YES.

The SVC won't rotate with the iPad correctly, even though the clock / status bar do.

<hr /><strong>Update</strong>

In my AppDelegate, I've noticed that the rootViewController isn't actually set until after I set it - shouldn't the rootViewController always be set? This code:

MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate]; NSLog(@"RootViewController pre set: %@", appDelegate.window.rootViewController); [appDelegate.window setRootViewController:splitViewController]; NSLog(@"RootViewController post set: %@", appDelegate.window.rootViewController);

Logs as:

RootViewController pre set: (null) RootViewController post set: <UISplitViewController: 0x88ad2d0>

Does this mean that I am mistaken in thinking the SVC is the root view controller?

Also, in IB - the window has nothing hooked up to the rootViewController outlet - is this a problem?

<hr />

Here's where the SVC is programmatically made:

-(IBAction)makeStory:(id)sender{ MakeSentenceTableViewController *detailViewController = [[MakeSentenceTableViewController alloc] initWithNibName:@"MakeSentenceTableViewController" bundle:nil]; UISplitViewController *splitViewController = [[[UISplitViewController alloc] init] autorelease]; UINavigationController *rootNav = [[[UINavigationController alloc] initWithRootViewController:makeStoryTableViewController]autorelease]; UINavigationController *detailNav = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease]; splitViewController.viewControllers = [NSArray arrayWithObjects:rootNav, detailNav, nil]; splitViewController.delegate = makeStoryTableViewController; MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate]; [appDelegate.window setRootViewController:splitViewController]; }

Here is the ShouldAutoRotate section in both tableviews (they're identical in both):

// Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { NSLog(@"story idiom for rotate is iPad"); return YES; }

Please help me fix this so that the SplitViewController loads correctly - or help me out with some techniques to debug (e.g. how could I check for sure that the SVC is in the rootViewController, are there other methods to debugging rotation hassles?).

Answer1:

Ah. So often part of the process in asking a question leads you to answer it to yourself.

I had to hook up the rootViewController outlet in IB for MainWindow~ipad.xib to the viewController in the AppDelegate, then everything started working.

So I hadn't correctly set the UISplitViewController as the rootViewController.

Recommend

  • warning: passing argument 3 of 'objc_setProperty' as signed due to prototype
  • How do I resize height of UINavigationBar while allowing to set root view controller?
  • Core Data lightweight migration crash
  • viewWillAppear is not called in my view controller when the app becomes active
  • Go back to previous view controller with help of swipe back (to the left)
  • numberOfRowsInSection called but cellForRowAtIndexPath not called
  • Vuejs $emit doesn't fire on callback
  • TeamCity - setParameter value available to Build Feature
  • firebase unauth with google doesn't allow change of user
  • System call time out?
  • Cannot update firebase version [duplicate]
  • Autohotkey script running program with command line arguments
  • Is there a way to choose which files are displayed to the user via the standard OPENFILE dialogs?
  • Can you pass an array from javascript to asp.net mvc controller action without using a form?
  • how to populate a SQLite database and use that database in phonegap?
  • Setting WPF Window Background to Resource Dictionary Brush User Setting
  • Most efficient way to move table rows from one table to another
  • HttpClient: disabling chunked encoding
  • HttpURLConnection Closing IO Streams
  • Servlet stops working on Tomcat server after some hits or time
  • How do I display a dialog that asks the user multi-choice questıon using tkInter?
  • PLSQL: Get number of records updated vs inserted when a merge statement is used
  • GAE: Way to get reference to an HttpSession from its ID?
  • Ajax Upload File: $_FILES is empty but files exists in request header
  • How do I configure context broker accept post requests from my remote sensor?
  • saving file generated by TCPDF
  • Eloquent update method change created_at timestamp
  • Display images in Django
  • Alert pop up with LWUIT
  • Get data from AJAX - How to
  • Disabling Alt-F4 on a Win Forms NotifyIcon
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • How to limit post in wp_query
  • AngularJs get employee from factory
  • Free memory of cv::Mat loaded using FileStorage API
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Memory offsets in inline assembly
  • Turn off referential integrity in Derby? is it possible?
  • How can I remove ASP.NET Designer.cs files?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize