How to detect touches on UIImageView of UITableViewCell object in the UITableViewCellStyleSubtitle style

In your cellForRowAtIndexPath method add this code cell.imageView.userInteractionEnabled = YES; cell.imageView.tag = indexPath.row; UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myFunction:)]; tapped.numberOfTapsRequired = 1; [cell.imageView addGestureRecognizer:tapped]; [tapped release]; And then to check which imageView was clicked, check the flag in selector method -(void)myFunction :(id) sender { UITapGestureRecognizer *gesture = (UITapGestureRecognizer *) sender; NSLog(@”Tag = %d”, gesture.view.tag); … Read more

Altering the background color of cell.accessoryView and cell.editingAccessoryView

Upon reading the documentation (a novel idea), I found the article, “A Closer Look at Table-View Cells”. It helped me understand the composition of the cells, and I found my answer… cells look like this… Since the cell.accessoryView is a sister view to cell.contentView I had to ask the cell.contentView for its superview, and then … Read more

uitableviewcell textlabel too long and push detailtextlabel out of view

Simplest for me was to subclass UITableViewCell and override the layoutSubviews. Couldn’t find a reliable way to calculate the positions from just the label frames so just hardcoded the accessory width for in this case a UITableViewCellStyleValue1 cell with a UITableViewCellAccessoryDisclosureIndicator accessory type. – (void)layoutSubviews { [super layoutSubviews]; CGFloat detailTextLabelWidth = [self.detailTextLabel.text sizeWithFont:self.detailTextLabel.font].width; CGRect detailTextLabelFrame … Read more

tech