Search code examples
iosswiftuibuttonuicontrol

UIButton title not set until view appear


I create an input toolbar with UITextView and UIButton. Just pin to the bottom of screen. Like that:

    override var inputAccessoryView: UIView? {
        return commentToolbar
    }

    override var canBecomeFirstResponder: Bool {
        return true
    }

When I push from other view controller. The title of UIButton not appear until view totally appear.

I wonder how can I set title to make its appear when controller just start pushing.

demo project: https://www.dropbox.com/s/7k04xum12iv4bnn/BlinkSendButton.zip?dl=0

Run that demo app. Tap one cell to push new view controller. You will see the no title set to UIButton before view totally appeared.

enter image description here


Solution

  • Just add...

    inputAccessoryView?.snapshotView(afterScreenUpdates: true)
    

    in your viewDidLoad of the ViewController.

    Btw this issue appeared also to others. I found the solution here: https://stackoverflow.com/a/36548797/8932493