开发者

How to prevent UITextField from displaying multiple lines?

开发者 https://www.devze.com 2023-01-25 17:28 出处:网络
Yes, you read right - my UITextField has multiple lines for some reason and it is driving me crazy. I have an app where users can edit content directly in a UITableViewCell. When they tap the cell,

Yes, you read right - my UITextField has multiple lines for some reason and it is driving me crazy.

I have an app where users can edit content directly in a UITableViewCell. When they tap the cell, the text in the cell's label is put into a UITextField that is then added to the UITableViewCell. Once the UITextField hits a certain amount of characters (not sure开发者_如何学Go exactly what the magic number is), it splits onto multiple lines and looks terrible - the first row is clear, but the second row is clipped by the bottom border of the UITextField.

I do not want to use a UITextView as I prefer the single line in my situation. Has anybody seen this behavior before? Is there a way to prevent it?

Oh, I am using iOS 4.1 as my base SDK.


Found it - the clipsToBounds property of the UITextField needs to be set to YES. If using Interface Builder, the "Clip Subviews" box needs to be checked.

0

精彩评论

暂无评论...
验证码 换一张
取 消