首页 > 代码库 > 让UIAlertController同时兼容iphone和ipad

让UIAlertController同时兼容iphone和ipad

让UIAlertController同时兼容iphone和ipad

by 伍雪颖

var alert = UIAlertController(title: nil, message: message, preferredStyle: UIAlertControllerStyle.ActionSheet)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (alert:UIAlertAction!) -> Void in
    println("You tapped OK")
}))
alert.popoverPresentationController?.sourceView = view
alert.popoverPresentationController?.sourceRect = sender.frame
self.presentViewController(alert, animated: true, completion: nil)


让UIAlertController同时兼容iphone和ipad