How to enable tap in leftView/rightView when UITextField disabled?
<p>I have a <code>UITextField</code> where I added an image in <code>rightView</code>. I've added a gesture to this <code>rightView</code> and I would want to make it work when <code>UITextField</code> is disabled because this view is displayed only when not editing.</p>

<p>Here's an image sample of what I want to achieve:
<a href="https://i.stack.imgur.com/TRhfe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TRhfe.png" alt="Webservice address"></a></p>

<ul>
<li>leftView is just an empty space;</li>
<li>rightView has just the image.</li>
</ul>

<p>Here's the code used to apply the appearance to the <code>UITextField</code> and apply the image to rightView:</p>

<pre><code>- (void)applyAppearanceToTextField:(UITextField *)textField withRoundingCorner:(UIRectCorner)corner withIcon:(NSString *)icon {
    CAShapeLayer *shape = [[CAShapeLayer alloc] initWithLayer:textField.layer.mask];
    UIBezierPath *shadow = [UIBezierPath bezierPathWithRoundedRect:textField.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(5, 5)];
    shape.path = shadow.CGPath;
    textField.layer.mask = shape;

    // Apply space to the left as a padding
    [textField setLeftView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, textField.bounds.size.height)]];
    [textField setLeftViewMode:UITextFieldViewModeAlways];

    // Add the icon image to the right view
    CGFloat height = textField.bounds.size.height;
    UIImage *image = [UIImage imageWithIcon:icon backgroundColor:[UIColor clearColor] iconColor:[UIColor grayColor] andSize:CGSizeMake(height / 2, height / 2)];
    image = [UIImage imageWithCGImage:image.CGImage scale:image.scale orientation:UIImageOrientationUpMirrored];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    [imageView setBounds:CGRectMake(5, 0, image.size.width, image.size.width)];
    [imageView setUserInteractionEnabled:YES];
    [textField setRightView:imageView];
    [textField setRightViewMode:UITextFieldViewModeUnlessEditing];
    [textField.rightView setExclusiveTouch:YES];

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleIconTap:)];
    [textField.rightView addGestureRecognizer:tapGesture];
}

- (void)handleIconTap:(UITapGestureRecognizer *)gesture {
    NSLog(@"handleIconTap");
}
</code></pre>

<p>In <code>viewDidLoad</code> I check if the field is filled so the field is disabled. How can I enable the tap in the leftView/rightView when the <code>UITextField</code> is disabled?</p>