开发者社区 问答 正文

关于swift button点击事件;判断输入框内容

判断输入框内容,若不为空值战网跳转,若为空值则跳出提示框
这是我button用touch up inside关联的函数。跳转界面用ViewController用modal方法连接SecondViewController。但运行不成功。

 @IBAction func choose(sender: AnyObject) {
    if(Name.text!==""){

    self.performSegueWithIdentifier("SecondViewController", sender: self)

    }else{

         let n=UIAlertController(title: "Sorry", message: "It is Wrong", preferredStyle: UIAlertControllerStyle.Alert)

        let cancelAction = UIAlertAction(title: "取消", style: UIAlertActionStyle.Cancel, handler: nil)

        let okAction = UIAlertAction(title: "好的", style: UIAlertActionStyle.Default, handler: nil)

        n.addAction(cancelAction)

        n.addAction(okAction)

        self.presentViewController(n, animated: true, completion: nil)

    }


}

展开
收起
爵霸 2016-03-09 15:47:49 3529 分享 版权
1 条回答
写回答
取消 提交回答
  • 不等于是这样写的: !=
    你多写了一个 =

    2019-07-17 18:56:19
    赞同 展开评论
问答分类:
问答地址: