I am using UIPopoverPresentationController
to present my tableView controller as PopOver. I am able to change its preferredContentSize to tableView contentSize as follows,
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear: animated];
self.preferredContentSize = self.tableView.contentSize;
}
Here the problem is the contentSize is getting changed immediately which is not looking good. I tried animating it like this but it doesn't work. Any help would be appreciated.
P.S. I tried changing the contentSize in viewWillAppear
but it doesn't work and I am using Objective C not Swift.
Try this:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear: animated];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.preferredContentSize = self.tableView.contentSize;
});
}