Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone: In landscape-only, after first addSubview, UITableViewController doesn't rotate properly
    text
    copied!<p>A minimal illustrative Xcode project for this is available on <a href="http://github.com/diffengr/iPhone-subview-landscape-bug" rel="nofollow noreferrer">github</a>. </p> <p>On my UIWindow, when I add second (and subsequent) UITableView's as subviews, they do not rotate properly, and thus appear sideways. This is only tested in the Simulator. Here's a little code for you:</p> <pre><code>- (void)applicationDidFinishLaunching:(UIApplication *)application { ShellTVC* viewA = [[ShellTVC alloc] initWithTitle:@"View A"]; ShellTVC* viewB = [[ShellTVC alloc] initWithTitle:@"View B"]; // The first subview added will rotate to landscape correctly. // Any subsequent subview added will not. // You may try this by various commentings and rearranging of these two statements. [window addSubview:[viewA tableView]]; [window addSubview:[viewB tableView]]; [window makeKeyAndVisible]; } </code></pre> <p>viewB appears sideways. Comment out the addSubview for viewB, and viewA appears correctly. Do that for viewA only, and viewB appears correctly. </p> <p>I am not creating these UITableViewControllers via NIBs, though the UIWindow is. </p> <p>In case you are wondering, ShellTVC is-a UITableViewController, and implements this method:</p> <pre><code>- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); } </code></pre> <p>Also, I have set the UIInterfaceOrientation in the plist file to UIInterfaceOrientationLandscapeLeft. </p> <p>Probably related -- and unanswered -- SO questions <a href="https://stackoverflow.com/questions/1484799">here</a> and <a href="https://stackoverflow.com/questions/1371007">here</a>.</p>
 

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