Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @IBAction func dialogButton(sender: AnyObject) {
- let optionMenu = UIAlertController(title: "Choose Your Option", message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)
- let option1 = UIAlertAction(title: "OptionTest1", style: .Default, handler: {
- (alert: UIAlertAction!) -> Void in
- println("Option 1")
- })
- let option2 = UIAlertAction(title: "OptionTest2", style: .Default, handler: {
- (alert: UIAlertAction!) -> Void in
- println("Option 2")
- })
- let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
- (alert: UIAlertAction!) -> Void in
- println("Cancelled")
- })
- optionMenu.addAction(option1)
- optionMenu.addAction(option2)
- optionMenu.addAction(cancelAction)
- if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Pad )
- {
- if let currentPopoverpresentioncontroller = optionMenu.popoverPresentationController{
- currentPopoverpresentioncontroller.sourceView = btn_button
- currentPopoverpresentioncontroller.sourceRect = btn_button.bounds;
- currentPopoverpresentioncontroller.permittedArrowDirections = UIPopoverArrowDirection.Up;
- self.presentViewController(optionMenu, animated: true, completion: nil)
- }
- }else{
- self.presentViewController(optionMenu, animated: true, completion: nil)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement