Question

I'm having a problem handling rotation in a view controller.

When the view is topmost and the phone is rotated, it adapts correctly.

When there's a view controller being presented modally over it and the device is rotated, the view controller under is not fully updated for the rotation when the user returns. The biggest problem I appear to be having is that the separator lines don't expand to fill the whole width.

Example:

enter image description here

I've uploaded my test project to GitHub; you can clone it from https://github.com/tewha/ResizeOnRotate.git.

I have no code handling rotation at all. My understanding was that this was supposed to be fully automatic. What am I missing to make this work correctly?

Edit:

Inspired by the answer below, a simple workaround:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    UITableViewCellSeparatorStyle separatorStyle = self.tableView.separatorStyle;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.separatorStyle = separatorStyle;
}
Was it helpful?

Solution

I think this may be an Apple bug. You can reproduce it in their own app "Mail".

Steps to reproduce in "Mail" app -

  1. Open Inbox of messages in "Mail" app. (say, in Portrait orientation)
  2. Tap compose message icon (bottom right) and rotate the device (in landscape).
  3. Close the compose message and see the inbox messages view now.

Result: The separator lines are broken.

Workaround for user: Scroll down and up in message inbox (leads to display refresh).

Reproducible up to iOS 7.0.2.

Edit

(Code workaround - 1)

If possible, you could reloadData to refresh the tableview when it appears.

- (void)viewWillAppear:(BOOL)animated
{
    [self.tableView reloadData];
}

Code workaround - 2 (reload only the visible cells)

- (void)viewWillAppear:(BOOL)animated
{
    NSArray *refreshCells = [self.tableView indexPathsForVisibleRows];

    [self.tableView reloadRowsAtIndexPaths:refreshCells withRowAnimation:UITableViewRowAnimationNone];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top