Resizing behavior of UIPopoverController differs between iOS 7.0 and iOS 7.1

孤街醉人 提交于 2019-12-04 14:43:41

This is a bug in popover controller in iOS7 and above. Please open a bug report with Apple in https://bugreport.apple.com and post the bug number in your question.

This happens due to resizing the popover controller in viewDidAppear. The key is to delay the resizing just a little bit, so that the popover controller can finish its layout. Using dispatch_async on the main queue, you register your block to run on a followup pass of the main runloop, which gives the popover controller enough time to "breed" and the bug is not reproduced.

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.tableView.frame = CGRectMake(0, 0, self.tableView.frame.size.width, 200);

    dispatch_async(dispatch_get_main_queue(), ^{
        [self.parentPopover setPopoverContentSize:[self contentSizeForViewInPopover] animated:NO];
    });
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!