Swift 显示alert

func Alert(title:String, msg:String)->Void{
        let alert = UIAlertController(title: title, message: msg, preferredStyle: UIAlertControllerStyle.alert)
        alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: nil))
        self.present(alert, animated: true, completion: nil)
    }

Swift 显示confirmation

let refreshAlert = UIAlertController(title: "", message: "Are you sure to continue?".localized(), preferredStyle: UIAlertControllerStyle.alert)

            refreshAlert.addAction(UIAlertAction(title: "Yes".localized(), style: .default, handler: { (action: UIAlertAction!) in
                // Cancel leave
                let result = ServiceProxy().CallCancelLeave(leaveId: self._leave.id)
                if(!result.isSuccess){
                    self.Alert(title: "Error".localized(), msg: result.errorMessage)
                }else{
                    // do nothing and navigate to the list view
                }
            }))

            refreshAlert.addAction(UIAlertAction(title: "No".localized(), style: .cancel, handler: { (action: UIAlertAction!) in
                // do nothing
            }))
            present(refreshAlert, animated: true, completion: nil)

Swift显示alert和promp confirmation的更多相关文章

  1. [Cordova] 无法显示Alert视窗

    [Cordova] 无法显示Alert视窗 问题情景 今天开了一个Cordova专案做范例,将预设的index.html页面修改为下列内容.按下执行却发现,这样一个简单的范例无法正常执行.点击页面上的 ...

  2. SWIFT显示底部的工具条

    有以下页面显示我的讯息,用户可以点击右上角的编辑按钮进入删除状态.点击编辑按钮后,按钮文字改为“取消”,左上角的按钮变为“全选”,同时显示底部工具条带有“删除”按钮 实现起来挺简单的,在正常状态下点击 ...

  3. Swift UI

    概述 Apple近日发布了Swift编程语言,Swift是供iOS和OS X应用编程的新编程语言.相信很多开发者都在学习这门新语言.   废话不多说,下面我就来学习使用Swift创建一个简单的UI应用 ...

  4. Swift学习之UI开发初探

    Swift是供iOS和OS X应用编程的新编程语言.相信很多开发者都在学习这门新语言.废话不多说,下面我就来学习使用Swift创建一个简单的UI应用程序. AD: 概述 Apple近日发布了Swift ...

  5. Swift UI开发初探

    今天凌晨Apple刚刚发布了Swift编程语言,Swift是供iOS和OS X应用编程的新编程语言.相信很多开发者都在学习这门新语言. 废话不多说,下面我就来学习使用Swift创建一个简单的UI应用程 ...

  6. iOS二维码扫描的实现(Swift)

    随着二维码的普遍使用,二维码扫描也成为了很多app的一个基本功能,本篇主要来介绍一下如何实现一个简单的二维码扫描功能.本文使用了XCode自带的AVFoundation 库,利用Swfit语言实现. ...

  7. Swift UI开发初探 (转)

    原文地址:http://www.tairan.com/archives/6600 关于Swift语法,可以参考<Apple Swift编程语言入门教程> 效果如下: 开发环境 Xcode6 ...

  8. iOS开发——UI篇Swift篇&UIAlertView/UIActionSheet

    UIAlertView/UIActionSheet UIAlertView //一个按钮的提醒 @IBAction func oneButtonAler() { //创建单一按钮提醒视图 let on ...

  9. Easyui弹出窗体在iframe的父级页面显示

    今天做EasyUI学习的预到了一个这样的问题:通过iframe加载的一个页面在调用$.messager.alert();这个方法后只能在iframe中显示alert效果而不是在全局的页面上显示这并不我 ...

随机推荐

  1. js中比较实用的函数用法

    <table id="table"> <tr> <th>用户ID</th> <th>用户名</th> < ...

  2. [转载]Javassist 使用指南(三)

    ======================= 本文转载自简书,感谢原作者!. 原链接如下:https://www.jianshu.com/p/7803ffcc81c8 =============== ...

  3. MySQL 删除重复记录

    ==========A really easy way to do this is to add a UNIQUE index on the 3 columns. When you write the ...

  4. linux一键安装php脚本

    #!/bin/sh echo "----------------------------------start install php --------------------------- ...

  5. ACM ICPC 2010–2011, Northeastern European Regional Contest St Petersburg – Barnaul – Tashkent – Tbilisi, November 24, 2010

    ACM ICPC 2010–2011, Northeastern European Regional Contest St Petersburg – Barnaul – Tashkent – Tbil ...

  6. SQL使用CASE 语句

    CASE 语句可以在SELECT 子句和ORDER BY 子句中使用 CASE语句分为两种Case Simple Expression and Case Search Expression Case ...

  7. 使用Bind读取配置到C#的实例

    在之前的一篇二级域名绑定的文章<.Net Core 二级域名绑定到指定的控制器>中,有一个小的地方是关于读取Json文件的配置信息的,当时是用了读取文件流的方式,一直以来觉得该方法太Low ...

  8. poj-3461-kmp模板题。。。

    Oulipo Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 46290   Accepted: 18452 Descript ...

  9. JS返回一个数据的千分位格式

    /** * 价钱转换-从右往左每3位数字加一个逗号 * @param price 需要转换的价格 */ formatPrice(price){ var newPrice = price.split(' ...

  10. IOS-UISearchBar

    UISearchBar控件   最近用到搜索功能.于是,经过不断的研究,终于,有点懂了. 那就来总结一下吧,好记性不如烂笔头! 搜索,无疑可以使用UISearchBar控件! 那就先了解一下UISea ...