开发者

UITableViewCell UILabel Vertical Alignment Seems Off

开发者 https://www.devze.com 2022-12-20 04:51 出处:网络
I have a simple application that uses a few non-standard UITableVie开发者_如何学运维wCellStyles (like UITableViewCellStyleValue1, UITableViewCellStyleValue2 or UITableViewCellStyleSubtitle).

I have a simple application that uses a few non-standard UITableVie开发者_如何学运维wCellStyles (like UITableViewCellStyleValue1, UITableViewCellStyleValue2 or UITableViewCellStyleSubtitle).

When I run the app in the Simulator all works just fine; but when I run the app on the Device, the UILabel's don't necessarily vertically line up in the middle of the cell. I've done some additional debugging and determined that when I use UITableViewCellStyleValue1 or UITableViewCellStyleValue2 - it seems that if I assign text to just "cell.textLabel.text", that label will appear 'higher' than the middle of the cell.

If I also assign text to "cell.detailTextLabel.text", then both of the labels are vertically centered. Furthermore, if I only assign text to "cell.detailTextLabel.text", then again, it is not vertically centered.

I am running Xcode 3.1.4 and deploying iPhoneOS 3.1.2 SDK to an first generation iTouch 32GB unit and not sure what is happening.


It seems like a bug to me, but a workaround is to set cell.detailTextLabel.text = @""; if you don't want any text to appear on the right side of the cell. Why it expects a string in both is bizarre but the above line worked around it for me.

0

精彩评论

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