the button is disabled when text view is empty else is enabled

后端 未结 3 673
庸人自扰
庸人自扰 2021-01-26 03:12

I\'m developing note app, when the text view is empty the done button should be disabled so user could not be able to save empty notes into data base, else the button should be

3条回答
  •  庸人自扰
    2021-01-26 03:52

    Try this in textViewDidChange method:

    yourBarButtonItem.isEnabled = !(yourTextField.text?.isEmpty ?? false)
    

提交回复
热议问题