@IBAction func signinButton(_ sender: AnyObject) {
self.ActivityIndicator.startAnimating()
let id = usernameTextField.text;
let pwd = passwordTextField.text;
if (id!.isEmpty || (pwd!.isEmpty)){
let alert = UIAlertController(title: "Information!", message: "Username and Password is not empety", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.destructive, handler: nil))
present(alert, animated: true, completion: nil)
self.present(alert, animated: true, completion: nil)
}
}
此错误: 警告:尝试显示其视图不在窗口层次结构中!
请帮帮我..
答案 0 :(得分:2)
试试这个(只删除最后一个self.present
行):
@IBAction func signinButton(_ sender: AnyObject) {
self.ActivityIndicator.startAnimating()
let id = usernameTextField.text;
let pwd = passwordTextField.text;
if (id!.isEmpty || (pwd!.isEmpty)){
let alert = UIAlertController(title: "Information!", message: "Username and Password is not empety", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.destructive, handler: nil))
present(alert, animated: true, completion: nil)
}
}
答案 1 :(得分:1)
您有2个present
个功能。所以只需更改您的代码:
present(alert, animated: true, completion: nil)
self.present(alert, animated: true, completion: nil)
为:
present(alert, animated: true, completion: nil)
答案 2 :(得分:0)
如何制作通知徽章。 如果在表格中重新加载时有新数据,则会像这样在tableview上显示通知标记。 enter image description here