Search code examples
iosxcodeinterface-builderxib

UIButton title set in Storyboard is missing when run


I am quite new to iOS development and I encountered a problem when I was trying out a simple calculator tutorial. For some reason, the "0" and "=" does not appear on the iOS simulator while it appeared perfectly fine on the user interface shown on XCode.

Any idea on how to resolve this problem?

Thanks! =)

enter image description here


Solution

  • One possibility could be that you accidentally set the titles of those two buttons on a control state other than default or UIControlStateNormal.

    The buttons in your screenshot are in a state called UIControlStateNormal because they aren't being tapped or disabled. Select the buttons and make sure the 'State Config' option in the Attributes inspector is set to 'Default' when you're setting your title in Storyboard.

    EDIT

    Autolayout sometimes causes unintended behavior like this. If you aren't relying on Autolayout and don't plan to, you can turn it off in the File inspector. If you are relying on Autolayout, you'll have to write some code to undo the unintended behavior it's causing.