0

I have some view controllers with many buttons. Now about a third of the buttons are only showing one line of text. The text was entered through the Attributes Inspector of the Storyboard (not programmatically).

There does not seem to be any pattern to the problem.

The buttons need to be small, so there are a few lines each (somewhere between two and eight).

Yes, the buttons are plenty big for all the text to show.

Xcode 4.6, Deployment target iOS 6.1, buttons are Type: Custom, State Config: Default, Title: Plain.

Any help would be greatly appreciated! You guys rock.

Edit: the storyboard file shows all the lines, but the iPad (simulator) is not.

bowtieguy
  • 21
  • 6
  • http://stackoverflow.com/questions/909150/multiline-uibutton http://stackoverflow.com/questions/604632/how-do-you-add-multi-line-text-to-a-uibutton – A-Live Apr 01 '13 at 16:57

2 Answers2

2

Set the lineBreakMode of the button textlabel to UILineBreakModeWordWrap (NSLineBreakByWordWrapping for Ios 6+). It should work

pdrcabrod
  • 1,467
  • 1
  • 14
  • 22
1

you can make

button.titleLabel.numberOfLines =0;

button.titleLabel behaves like UILabel. all properties of UILabel is valid.

edit: in the .xib file click button you want to change. in "line break" choose "word wrap"

meth
  • 1,887
  • 2
  • 18
  • 33