2

I have NSTextField containing a long string, I would like the string to be split in several lines. But now if I limit the length of the view I see the string clipped. I have tried also to use cell's setWraps method and setLineBreakMode:NSLineBreakByWordWrapping but the problem is still there

What can I try? I am working on mac OS application (not Iphone)

Thanks in advance

RuLoViC
  • 825
  • 7
  • 23

2 Answers2

1

Finally I was able to fix this problem. Solution was quite simple. Modifying the nib file by changing

 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>

by

 <autoresizingMask key="autoresizingMask" />

And giving the textfield the desired width

RuLoViC
  • 825
  • 7
  • 23
-1

Are you calling setWraps: after the text field is in focus? The field editor would be the one getting in the way. If you resign the first responder first, then it should work:

[window makeFirstResponder:nil];
[[textField cell] setWraps:YES];
Kevin Low
  • 2,672
  • 16
  • 17
  • I have tried that and it does not work. When should I call the setWraps? Now i am calling it in the init method, but the text is set after. – RuLoViC Sep 05 '15 at 06:00
  • I am using a nib file to create the view and I am initialising it and adding the text in NSViewController class. Am I missing something? – RuLoViC Sep 05 '15 at 06:02