Custom accessoryView image and accessoryButtonTappedForRowWithIndexPath
I am trying to get a custom image working with the
accessoryButtonTappedForRowWithIndexPath function. From what I understand
in order to do this, you have to use a UIBUtton, simply adding a
UIImageView on the UITableViewCellAccessoryDetailDisclosureButton will not
work.
My problem is how to get the touch gesture from my UITableViewCell
subclass into the parent UITableView function.
Here is the code in my TableViewCell subclass:
upVote = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *upVoteImg = [UIImage imageNamed:@"vote.png"];
upVote.frame = CGRectMake(self.frame.size.width-upVoteImg.size.width, 0,
upVoteImg.size.width , upVoteImg.size.height);
[upVote setBackgroundImage:upVoteImg forState:UIControlStateNormal];
[self.contentView addSubview:upVote];
[upVote addTarget:self action:@selector(checkButtonTapped:event:)
forControlEvents:UIControlEventTouchUpInside];
The calling function (also inside the subclass of the TableViewCell
- (void)checkButtonTapped:(id)sender event:(id)event
{
UITableView *tableView = (UITableView *)self.superview;
[tableView.delegate tableView:tableView
accessoryButtonTappedForRowWithIndexPath:[tableView
indexPathForCell:self]];
}
It crashes at the final line of the above function with this:
* Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UITableViewWrapperView delegate]: unrecognized selector sent to
instance 0x16f48160'
No comments:
Post a Comment