Reputation: 1005
I have created a custom cell for my TableView to show 1 ~ 5 rows of information in each cell. So, I have to create UILabels and UISwitches for each row of data in code, and Add them as subViews to my custom cell.
I tried to add UI Controls in cellForRowAtIndexPath
method before returning the custom cell with no success. Tried to add a viewDidLoad
method in my customCell.m file and create controls in it, but UITableViewCell does not have a viewDidLoad
method.
Where should I create UIs and how can I add them to customCell?
Upvotes: 0
Views: 351
Reputation: 49057
In this if you subclassed UITableViewCell:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
And add UI elements to self.contentView as subviews while you are in this function.
Upvotes: 2