How do I customize each cell in a UITableView
(like each cell will have UITextfield
and UIButton
)?
2 Answers
UITableView
cells respond to selections - it get's handled in tableView:didSelectRowAtIndexPath
, maybe this satisfies your UIButton requirement. In case where you need UIButton it should not be difficult - it is just another UIView component.
Easy custom UITableView drawing is a detailed article on customizing UITableView
. It goes beyond what you want but you may find useful details. Have a look at section Layout within the contentView for how to add views to cell - the example adds image and text (lots of custom background stuff going on).
Example code discussed here:
UIView* container = [[UIView alloc] initWithFrame:goodRect];
UITableView* tv = [[UITableView alloc] initWithFrame:tableRect];
UIButton* btn = [[UIButton alloc] initWithFrame:btnFrame];
[container addSubview:tv];
[container addSubview:btn];
myController.view = container;
Maybe have a look at question UIButton in a UITableView header ignores most touches.
There era a few subViews in table cell that you can modify. Good tutorial that I found is here: http://www.cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html

- 37,241
- 25
- 195
- 267

- 1,363
- 2
- 10
- 25
-
I thought of that one as well - classic tutorial. – Kobski Sep 04 '12 at 19:10