is it possible to update UIButton title/text programmatically?

后端 未结 12 1809
北海茫月
北海茫月 2020-12-07 19:58

I have a UIButton, that when pressed, brings up a new view where the user can change some settings. When the view is dismissed, I\'d like to update the title/t

12条回答
  •  误落风尘
    2020-12-07 20:22

    One more possible cause is this:

    If you attempt to set the button's title in the (id)initWithNibName: ... method, then you're button property will still be nil. It hasn't yet been assigned to the UIButton.

    You must be sure that you're setting your buttons in a method like (void)viewWillLoad or (void)viewWillAppear, but you probably don't want to set them as late as (void)viewDidAppear.

提交回复
热议问题