开发者

how do i fully customize a tableview

开发者 https://www.devze.com 2023-01-23 14:45 出处:网络
i want to customize my tableview, like the tipulator app for the iph开发者_运维知识库one. And heres my app:

i want to customize my tableview, like the tipulator app for the iph开发者_运维知识库one.

how do i fully customize a tableview

And heres my app:

how do i fully customize a tableview


Each UITableViewCell has a few subviews which you can replace with your own. They are:

  • UITableViewCell.imageView
  • UITableViewCell.contentView
  • UITableViewCell.backgroundView
  • UITableViewCell.accessoryView

As Gendolkari pointed out, Cocoa With Love has a great guide on custom UITableViews.

The theory is that you replace each of those views with an appropriate view to "skin" your UITableViewCells.

When replacing the background view, you check for the first and last cells when skinning the background view, otherwise you can use a "middle" background image. Implement it as a UIImageView. As far as the other views, use what you want.

Additionally, you can use a completely custom NIB file and load that in instead of the default styles provided by UIKit.


While the others are right in suggesting ways to subclass UITableView or its components, this screenshot doesn't look like it's showing a UITableView.

My guess is that they're just drawing custom images onto a background and checking certain areas for taps. What you should do is read up on the drawing methods as well as on intercepting taps and touches.


Here's a really good guide on custom styling for your table:

http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html


Create your own UITableViewCell, and use it, rather than a "generic" one.

You can do this directly in XCode with "File->New File" Then in "Cocoa Touch Class", choose "Objective-C Class" - and under the "Subclass" popup, select "UITableViewCell".

It well generate a XIB, which you can use in IB to customize the look.

Instantiate and pass-in there cells in your UITableView code, instead of the normal UITableViewCells.

0

精彩评论

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

关注公众号