UIAlertController is Crashed (iPad)

后端 未结 10 1768
长情又很酷
长情又很酷 2020-12-13 17:58

I am using Xcode 6 to develop an iOS Application.

When I used UIAlertController, it can be worked well on iPhone 6 simulator, but crashes on iPad simula

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 18:50

    To keep it device independent, rather use it as shown in the snippet below. This code will return nil for popoverPresentationController on an iPhone / compact size device, so you can safely use it in universal projects.

    if let popoverPresentationController = shareMenu.popoverPresentationController {
        popoverPresentationController.sourceView = self.view
        popoverPresentationController.sourceRect = sender.bounds
    }
    self.presentViewController(shareMenu, animated: true, completion: nil)
    

提交回复
热议问题