Resizing a presenting view on rotate

偶尔善良 提交于 2019-12-22 09:13:54

问题


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:

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;
}

回答1:


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];
}


来源:https://stackoverflow.com/questions/19390566/resizing-a-presenting-view-on-rotate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!