1.相关代码如下
iOS9.0中,苹果官方推荐使用UIAlertViewController取代之前UIAlertView,使用UIAlertView在Xcode7中会出现警告。
ViewController.swift代码如下:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let button1 = UIButton()
let button2 = UIButton()
button1.frame = CGRectMake(50, 50, 100, 30)
button1.setTitle("Alert", forState: UIControlState.Normal)
button1.backgroundColor = UIColor.blackColor()
button1.addTarget(self, action: "AlertClicked:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(button1)
button2.frame = CGRectMake(50, 100, 100, 30)
button2.setTitle("ActionSheet", forState: UIControlState.Normal)
button2.backgroundColor = UIColor.blackColor()
button2.addTarget(self, action: "ActionSheetClicke