Search code examples
iosuitableviewaccessory

Make Accessory indicator clickable


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"]];

Solution

  • 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.