In my nib file, I have an outlet connected a UIButton for the UITableViewCell. Where can I set the image for the different states of the button in code?
By default, there is a method
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
}
I tried setting my image for UIControlStateNormal and UIControlStateSelected, but I don’t see my states when I load the TableViewCell. I load the TBvCell using the UINib method:
MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:@"MyCellIdentifier"];
if (cell == nil) {
UINib *cellNib = [UINib nibWithName:@"MyCell" bundle:nil];
[cellNib instaniateWithOwner:self options:nil];
cell = self.MyCell;
self.MyCell = nil;
}
return cell;
Thanks.
You can set all this in Interface Builder itself. Unless you have very string reasons to do it in code. Here’s how to do it in IB –
Open the right side bar & then click on “State Config”, there you see the various states of the button, Default, Highlighted, Selected & Disabled. Now you can set different images for each state, different font type & font colors for each state. Hopr this helps…