-1

I have this app that was previously developed and maintained at Xcode 7. But recently we had to upgrade Xcode to 10 to be able to post the app to apple store.

Many layout were broken upon the update and this seems to be a known issue ref. I believe it is the AutoLayout problem. I fixed them by going to storyboard to add the required constraints.

However there is a problem with one of the popovercontroll that I do not know how to fix.

Here is how it should look: enter image description here

Here is how it look after the upgrade: enter image description here

The popover is not showing.

The code has not changed. It is a custom table view controller inherited from UITableViewController. I tried update frame but it did not work. The code that should pop up the view:

UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
UNISortTableViewController *contentViewController = [storyBoard instantiateViewControllerWithIdentifier:@"UNISortTableViewController"];

((UNISortTableViewController *)contentViewController).sortKeyArray = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", nil];
[(UNISortTableViewController *)contentViewController setPreviousSortKeyIndex:sortKeyIndex];
[(UNISortTableViewController *)contentViewController setPreviousSortOrder:ascIssues];

self.popoverController = [[popoverClass alloc] initWithContentViewController:contentViewController];

if ([self.popoverController respondsToSelector:@selector(setContainerViewProperties:)]) {
    [self.popoverController setContainerViewProperties:[self improvedContainerViewProperties]];
}

self.popoverController.delegate = self;
contentViewController.delegate = self;

[self.popoverController presentPopoverFromBarButtonItem:sender
                               permittedArrowDirections:(UIPopoverArrowDirectionUp|UIPopoverArrowDirectionDown|
                                                         UIPopoverArrowDirectionLeft|UIPopoverArrowDirectionRight)
                                               animated:YES];

When debug I can see that cellforrowatindexpath event is not called

  • Does your code use the UIPopoverController? This object was deprecated in iOS 9, so, there are other options that you have to code around. – Michael Dougan Jun 12 at 22:45
  • @Michael Dougan I update with the triggering code.. Not sure if self.popoverController is the same as UIPopoverController. But it works in iPad.. – Frostless Jun 12 at 23:49
1

Your antiquated code is calling initWithContentViewController. This suggests that you are using UIPopoverController, which was deprecated after iOS 9.

https://developer.apple.com/documentation/uikit/uipopovercontroller/1624669-initwithcontentviewcontroller?language=objc

You need to modernize your approach to popovers. Nowadays, popovers are simply a variety of presented view controller. There is no such thing as a UIPopoverController any more. You just call presentViewController on a normal UIViewController with a modalPresentationStyle of UIModalPresentationPopover. The entire way you designate where the arrow goes has changed too, but I won't go into detail, as the full information is available in the docs and elsewhere.

0

Seems like Xcode 10 the popoverContentSize becomes 0,0

I ended up using the following code

  if (!([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad))
{
    self.popoverController.popoverContentSize = contentViewController.preferredContentSize;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.