开发者

Custom touch area on tableview cell with checkbox iphone

I've added a checkbox to a table view cell which is a custom button with two images. Clicking this works fine as I can check and uncheck.

The problem is when you click the rest of the row it still selects the checkbox/button. If I comment out didSelectRowAtIndexPath it doesn't happen so I'm wondering how to get around this happening?

A solution I'd be happy with is to allow only selection of the Accessory Disclosure Indicator but there doesn't seem to be a way of doing this.

Sorry if this is a really badly asked question, I'm very tired! Let me know if 开发者_运维知识库you need code.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

WedAppDelegate *delegate = (WedAppDelegate *)[[UIApplication sharedApplication] delegate];

PlanTaskShowViewController *planTaskShowViewController = [[PlanTaskShowViewController alloc] initWithNibName:@"PlanTaskShowViewController" bundle:nil];

[delegate.navController pushViewController:planTaskShowViewControlleranimated:YES];

[planTaskShowViewController release];
}


put an button on the front instead of an image and do the selecting thing only when button is clicked (change the image of the button).

OR

put an on click event listener / gesture recognizer on your image

UITapGestureRecognizer *singleFingerDTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeImage:)];
[imageView addGestureRecognizer:singleFingerDTap];
[singleFingerDTap release];

//EDIT:

If you use highlightedImage for your UIImageView or UIButton it will be highlighted when selecting the UITableViewCell. It's a really nice feature, but sometimes it's only confusing ;)


Check this :

UITapGestureRecognizer *singleFingerDTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeImage:)]; [imageView addGestureRecognizer:singleFingerDTap]; [singleFingerDTap release];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜