开发者

Add right margin for detailTextLabel in UITableViewCell

What's the e开发者_开发百科asiest way to add right margin to detailTextLabel inside an instance of UITableViewCell?


The detailTextLabel used by the standard UITableViewCellLabel is not a standard label but a special subclass, private, called UITableViewLabel. Customizing it it's not easy as you probably experienced as some methods are overridden by the subclass. You can take some control by de-queing the cell from a reusable pool (because in such case the cell is not recreated and so some of the overridden methods are not called again and in such case basic UILabel settings will apply) but the result couldn't be satisfactory.

So the best approach for custom views is not to try to tweak the existing on-the-shelf views but make a custom cell. This can be done programmatically in the tableView:cellForRow:atIndexPath: delegate method, or by creating a UITableView subclass or loading it from a nib file. Even for simple changes like this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜