Advertisement
Quadref

Untitled

Dec 17th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.53 KB | None | 0 0
  1. @IBAction func dialogButton(sender: AnyObject) {
  2.     let optionMenu = UIAlertController(title: "Choose Your Option", message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)
  3.        
  4.        let option1 = UIAlertAction(title: "OptionTest1", style: .Default, handler: {
  5.            
  6.            (alert: UIAlertAction!) -> Void in
  7.            println("Option 1")
  8.        })
  9.        
  10.        let option2 = UIAlertAction(title: "OptionTest2", style: .Default, handler: {
  11.            
  12.            (alert: UIAlertAction!) -> Void in
  13.            println("Option 2")
  14.        })
  15.        
  16.        let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
  17.            (alert: UIAlertAction!) -> Void in
  18.            println("Cancelled")
  19.        })
  20.        
  21.        optionMenu.addAction(option1)
  22.        optionMenu.addAction(option2)
  23.        optionMenu.addAction(cancelAction)
  24.        
  25.        
  26.        if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Pad )
  27.        {
  28.            if let currentPopoverpresentioncontroller = optionMenu.popoverPresentationController{
  29.                currentPopoverpresentioncontroller.sourceView = btn_button
  30.                currentPopoverpresentioncontroller.sourceRect = btn_button.bounds;
  31.                currentPopoverpresentioncontroller.permittedArrowDirections = UIPopoverArrowDirection.Up;
  32.                self.presentViewController(optionMenu, animated: true, completion: nil)
  33.            }
  34.        }else{
  35.            self.presentViewController(optionMenu, animated: true, completion: nil)
  36.        }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement