Reputation: 5051
How do I customize each cell in a UITableView
(like each cell will have UITextfield
and UIButton
)?
Upvotes: 4
Views: 3468
Reputation: 1393
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
Upvotes: 1
Reputation: 79790
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.
Upvotes: 3