문제

I am showing a custom accessory view within my uitableview using the code below. Is it possible to target the accessory image as clickable? Do I need to make it a action? I need to make only the image clickable as within didSelectRowAtIndexPathI am producing a alert for another function.

cell.accessoryView = [[ UIImageView alloc ]
                          initWithImage:[UIImage imageNamed:@"acc_icon.png"]];
도움이 되었습니까?

해결책

You can make the accessory view a button or keep the image view and add a gesture recognizer (be sure to enable user interaction).


Instead of

[[UIImageView alloc] initWithImage...

Use

[UIButton buttonWithType...

And configure the button target, action, image / text.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top