Enable a button in Swift only if all text fields have been filled out

前端 未结 10 761
误落风尘
误落风尘 2020-12-01 01:20

I am having trouble figuring out how to change my code to make it so the Done button in the navigation bar is enabled when my three text fields are filled out.

I cur

10条回答
  •  爱一瞬间的悲伤
    2020-12-01 01:50

    The best way would be to Add observer in ViewDidLoad method. Than just check in textField Delegate method whether all TextFields are filled up or not. Once its filled up call oberserver method & in that you just need to enable button.

    Note:

    • You can use observer for both enable or disable button

    Hope it will help you.

提交回复
热议问题