iPad rotation problems, an update.

So having created a separate test app which does not exhibit the problem I ported some of that code into my app which then starts to exhibit the issue I conclude that the problem lies within the view containing the toolbar and the table view. I’d read elsewhere that having a view controller within a view controller is a bad idea so I’m refactoring the code to:

  • Get rid of the recipe view controller.
  • Incorporate it’s toolbar and split view code into the recipedetailtableviewcontroller_ipad class.

This actually simplifies things as we have less inter class interaction messages and delegates to sling around.  However this causes one minor problem.  The iPad class inherits from a shared parent ‘common’ class which itself inherits from UITableViewController.  The problem here is that the main view is expected to be a UITableView.  In the iPad it won’t be.  So I have to recode from bottom back up.  UITableViewController is a convenience class that defines the datasource and views for us.  So we can junk it in favour of a UIViewController and code the other stuff in manually.  What this means is we need to:

  • Turn the common class into a UIViewController with the UITableView stuff built in and appropriate delegate protocols added to the .h.
  • Ensure that the iPhone class has a view defined either in code or via a nib.
  • Then the iPad class should work from the xib that was originally used.

If this doesn’t fix the view rotation issue it does give me one less view controller and view to worry about and a much simpler overall schematic for the iPad version at the expense of more manual work further down, but no less efficient as the defined UITableViewController is simply a convenience system and not voodoo, and a slightly more complicated iPad recipe view controller as it will have code in it to handle the recipe table view popover and the splitview view view view.

UPDATE:  This solved the problem.  The common class is a UIViewController with a property for a UITableView.  The iPhone version creates the table programmatically without a nib interface file:

recipeTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 416) style:UITableViewStyleGrouped];

The iPad version uses the same nib file as before but with the UITableViewController deleted.  Right back to emailing recipes around the place.

This entry was posted in Programming and tagged , , , . Bookmark the permalink.