开发者

TableViewCell in IB or Programmatically, which one is better for customization?

I'm coding a custom TableViewCell and I need to set a background image for each one (actually same background image on all cells) and I'll add some labels for different type of texts (different in font, size, color, etc...) and a left image hosted on a web server. I'v开发者_开发知识库e read a tutorial on how to make the TableViewCell using IB and add it to cellForRowAtIndePath method. It worked but the image size and texts in labels are not showing like I was seeing them in IB, not wysiwyg at all lol

So, I need your help to choose the proper way to customize these cells, should I go for the IB way or programming tips are better?

Thx in advance for helping,

Stephane


I am guessing that the size of your images is going beyond the expected size of the imageView property for the left image. That usually pushes around all the other UI elements. You can avoid that by setting imageView.layer.masksToBounds of your cell to YES.

In general, for the problem you describe, I would recommend doing everything programmatically. You will have the opportunity for abstraction and include your program logic more economically.

To keep your cellForRowAtIndexPath method reasonably short, you can call your own formatCellAtIndexPath method and keep the formatting logic neatly separated from the content.


I find it easiest to create the TableViewCell in IB to start with and then, when I have it looking the way I like it, to switch to a cell built programatically.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜