swift 创建第一个UIAlertView 和UIActionSheet
2018-02-03 12:54
453 查看
//创建 UIActionSheet
//一定要指明类型。不编译不通过
func ActionSheet(sender:UITapGestureRecognizer)
{
let actionSheet: UIActionSheet = UIActionSheet(title:"Are you sure?", delegate:self, cancelButtonTitle:"Cancel", destructiveButtonTitle:"Yes,I'm sure!");
actionSheet.showInView(self.view)
}
//actionSheet delegate
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
if buttonIndex == 0{
println("点击位置为\(buttonIndex)")
}
}
//创建UIAlertView
func firstSwift(sender:UIButton)
{
println("第一个button的点击事件")
self.label1.text = "button点击了"
var alert = UIAlertView(title: "⚠", message: "button被点击了", delegate: self, cancelButtonTitle: "知道了")
alert.show()
}
//一定要指明类型。不编译不通过
func ActionSheet(sender:UITapGestureRecognizer)
{
let actionSheet: UIActionSheet = UIActionSheet(title:"Are you sure?", delegate:self, cancelButtonTitle:"Cancel", destructiveButtonTitle:"Yes,I'm sure!");
actionSheet.showInView(self.view)
}
//actionSheet delegate
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
if buttonIndex == 0{
println("点击位置为\(buttonIndex)")
}
}
//创建UIAlertView
func firstSwift(sender:UIButton)
{
println("第一个button的点击事件")
self.label1.text = "button点击了"
var alert = UIAlertView(title: "⚠", message: "button被点击了", delegate: self, cancelButtonTitle: "知道了")
alert.show()
}
相关文章推荐
- swift 创建第一个UIAlertView 和UIActionSheet
- IOS第12天(1,UIViewController控制器的创建的 三种方式,和第一个view创建)
- [iOS]swift之UITableView添加通过xib创建的headerView坑爹问题
- iOS8.0 之后UIAlertView和UIActionSheet的创建方式的新变化
- swift:创建表格UITableView
- swift中UIAlertView的使用
- iOS 8及以后版本 如何创建UIAlertView?
- 一步步的教你如何创建第一个APP?-swift
- UI5_UIAlertView与UIActionSheet
- Swift - 告警框(UIAlertView)的用法
- iOS8.0 之后UIAlertView和UIActionSheet的创建方式的新变化
- IOS-UIAlertView和UIActionSheet
- iOS 在一个屏幕中根据不同的按钮创建不同的 view 默认显示第一个
- 创建没有标题的UIAlertView,创建没有按钮的UIAertView
- Swift基础教程(swift代码创建第一个控件之UILabel)
- swift - UIAlertView 的用法
- Swift基础(二十二)UIAlertView,UIActionSheet,UIAlertController
- Swift-iOS常用控件(UIAlertView警告视图)
- UIAlertView与UIActionSheet的动态添加
- Swift - UIAlertViewCtl弹出框的使用,项目亲测。