Swift操作表(UIActionSheet)的用法,也叫底部警

2016-06-29  本文已影响172人  MangoJ
import UIKit

class ViewController: UIViewController        ,UITextFieldDelegate,UITextViewDelegate,UIActionSheet  Delegate,UIAlertViewDelegate{
override func viewDidLoad() {
    super.viewDidLoad()


let actionSheet = UIActionSheet()
    actionSheet.addButtonWithTitle("取消")
    actionSheet.addButtonWithTitle("ONE")
    actionSheet.addButtonWithTitle("TWO")
    actionSheet.cancelButtonIndex = 0
    actionSheet.delegate = self
    actionSheet.showInView(self.view)
//        actionSheet.showInView(self.view);  //一般情况
//        actionSheet.showFromToolbar(self.navigationController.toolbar)  //工具条的情况下
//        actionSheet.showFromTabBar(self.tabBar)  //标签条的情况下

 } 

 func actionSheet(actionSheet:UIActionSheet,didDismissWithButtonIndex buttonIndex:Int){
    print("点击: "+actionSheet.buttonTitleAtIndex(buttonIndex)!)
}

}
上一篇下一篇

猜你喜欢

热点阅读