var actionSheet:UIAlertController = UIAlertController(title: "title")", message: "", preferredStyle: UIAlertControllerStyle.ActionSheet)
actionSheet.addAction(UIAlertAction(title: title as String, style: UIAlertActionStyle.Destructive, handler: {
handle in
}))
//如果是在ipad上面弹出actionsheet,则需要指定其弹出的位置,不然在弹出时崩掉。这个在官方文档中未作说明。
if IsIpad() {
actionSheet.modalPresentationStyle = UIModalPresentationStyle.Popover
var popPresenter:UIPopoverPresentationController = actionSheet.popoverPresentationController!
popPresenter.sourceView = self.addToButton
popPresenter.sourceRect = self.addToButton!.bounds
self.viewController?.presentViewController(actionSheet, animated: true, completion: {
})
}else{
self.viewController?.presentViewController(actionSheet, animated: true, completion: {})
}