Swift UIAlertController -> ActionSheet iPad iOS8 Crashes

前端 未结 8 1492
北恋
北恋 2020-12-02 12:20

currently i\'m running into big trouble with my ActionSheet. On iPhone it works great, but on iPad it only crashes

I create a new project with only one button

<
8条回答
  •  臣服心动
    2020-12-02 12:26

    Nate Cook is totally right however I would do it so I detect if it is iPad or iPhone.

    This is for barButtonItem:

    if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad ){
    
                if let currentPopoverpresentioncontroller = alertController.popoverPresentationController{
                    currentPopoverpresentioncontroller.barButtonItem = sender as! UIBarButtonItem
                    currentPopoverpresentioncontroller.permittedArrowDirections = UIPopoverArrowDirection.down;
                    self.present(alertController, animated: true, completion: nil)
                }
            }else{
                self.present(alertController, animated: true, completion: nil)
            }
    

提交回复
热议问题