Swift 2.0 UIAlertView 和 UIActionSheet 的使用

 在 IOS 9.0 以後, UIAlertView  是 給廢棄了的,雖然你要使用的話,暫時仍是能夠的,可是在 9.0 以後,IOS 推薦你們使用的是  UIAlertController 這個控制器。下面是它的使用。swift

//  在 IOS 9.0 以後, UIAlertView  是 給廢棄了的,雖然你要使用的話,暫時仍是能夠的,可是在 9.0 以後,IOS 推薦你們使用的是  UIAlertController 這個控制器。下面是它的使用。
        let alview:UIAlertController = UIAlertController(title: "提示", message: "您點擊了cell", preferredStyle: UIAlertControllerStyle.Alert)
        
        let action:UIAlertAction = UIAlertAction (title: "取消", style: UIAlertActionStyle.Cancel) { (action) -> Void in
        
            // 取消添加的點擊事件
            print("好想你")
        }
        
        let actionOK:UIAlertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) { (actionOK) -> Void in

            // OK 的點擊事件
            print("你還好嗎")
        }

        // 這裏就是添加一個 事件 上去的感受, 只是這個  事件  是有類型 ,好比 刪除, 取消
        alview .addAction(actionOK)
        alview .addAction(action)
        self .presentViewController(alview, animated: true) { () -> Void in
       
        }
相關文章
相關標籤/搜索