3

I have a popup class to handle the popup issue but i cannot figure out why iPhone 6s plus cannot set the fixed height and the same code works fine on iPhone 6s.

Please help and advise if any idea. Thanks you.

The output on iPhone 6s plus: The output on iPhone 6s plus

The output on iPhone 6s (Expected output): The output on iPhone 6s (Expected output)

Popup Function Code:

func showPopover(segue: UIStoryboardSegue?, sender: AnyObject?, controller:UIViewController, animated:Bool) {
    let senderView = sender as! UIView
    controller.modalPresentationStyle = UIModalPresentationStyle.Popover
    controller.popoverPresentationController?.delegate = self
    controller.popoverPresentationController?.sourceView = senderView
    controller.popoverPresentationController?.sourceRect = senderView.bounds;
    self.presentViewController(controller, animated: animated, completion: nil)
}

Popup Function Call:

if let controller = segue.destinationViewController as? TeamMenuPopupTableViewController {
            controller.rosterHandler = self.homeRoster
            controller.timeoutHandler = self.homeTimeout
            controller.boxscoreHandler = self.homeBoxscore
            controller.preferredContentSize = CGSize(width: 200, height: 132)
            showPopover(segue, sender: sender, controller: controller, animated:false)
        }
IKit Chu
  • 41
  • 6
  • 1
    I think you have a size class issue - take a look here: http://stackoverflow.com/questions/30378249/uimodalpresentationpopover-for-iphone-6-plus-in-landscape-doesnt-display-popove – sschale Apr 01 '16 at 06:23
  • I am using the following swift code to handle the size class issue. No luck yet. @available(iOS 8.0, *) func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle { // Return no adaptive presentation style, use default presentation behaviour return UIModalPresentationStyle.None } – IKit Chu Apr 01 '16 at 07:11
  • Try updating to Xcode 7.3 and see if it helps. – Dan Levy Apr 01 '16 at 23:22

1 Answers1

1

I found the solution on internet and it should add this function to handle iPhone plus case.

func adaptivePresentationStyleForPresentationController(
    controller: UIPresentationController, 
    traitCollection: UITraitCollection) 
    -> UIModalPresentationStyle {
        return .None
}

For the detail, please check this link. Why isn't preferredContentSize used by iPhone 6 Plus Landscape?

Community
  • 1
  • 1
IKit Chu
  • 41
  • 6