kglin-King 2015-11-17 06:02 采纳率: 0%
浏览 1908

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)

    }

}

  • 写回答

3条回答 默认 最新

  • qq_26498287 2015-11-26 01:59
    关注

    if (name。text !=@“”)
    试试

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器