iOS9中提示框UIAlertController的用法

 

import UIKit

class ViewController: UIViewController {

//按钮的点击事件

@IBAction func clickedBtn(sender: AnyObject) {

//print(“click ok”)

let btnAlert = UIAlertController()

btnAlert.title = “系统提示”;

btnAlert.message = “这已经点击过了这个按钮”

 

//cancel按钮

let cancelAction = UIAlertAction(title: “cancel”, style: UIAlertActionStyle.Cancel, handler: nil)

 

//ok按钮

let okAction = UIAlertAction(title: “ok”, style: UIAlertActionStyle.Default){

(action: UIAlertAction!) -> Void in

print(“you choose ok”)

}

 

//将提示信息与用户扣作行为绑定

btnAlert.addAction(cancelAction)

btnAlert.addAction(okAction)

 

//

self.presentViewController(btnAlert, animated: true, completion: nil)

 

}

 

 

override func viewDidLoad() {

super.viewDidLoad()

// Do any additional setup after loading the view, typically from a nib.

}

override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.

}

}

1 thought on “iOS9中提示框UIAlertController的用法

  1. Pingback: real estate for sale in Winston Salem NC

Comments are closed.