Susitha
Susitha

Reputation: 3349

How to resize input accessory view

Working with show hide iphone keyboard with image button, that on the top of the keyboard.

    [kbdImage setFrame:CGRectMake(290, 0, 30, 30)];                                                             
    [accessoryView setFrame:CGRectMake(290, 0, 320, 30)];

    UITapGestureRecognizer *gestureRecogniser = [[UITapGestureRecognizer alloc]    initWithTarget:self action:@selector(hideKeyBoard:)];
     gestureRecogniser.numberOfTapsRequired = 1;

     [accessoryView addSubview:kbdImage];
     [accessoryView addGestureRecognizer:gestureRecogniser];


     for (UIView* v in searchBar.subviews) {
        if ([v isKindOfClass:[UITextField class]]) {
           ((UITextField*)v).inputAccessoryView = accessoryView ;
        }
     }

This works for hide keyboard. But the remaining area in the input view also touchable. How to avoid this.

Upvotes: 0

Views: 515

Answers (1)

Dilip Manek
Dilip Manek

Reputation: 9143

This is happening because you are adding tap gestures to the whole AccessoryView so the whole View will be responding to tap gestures, instead of it adding tap gestures to only that image button.

    kbdImage.userInteractionEnabled = YES;
    [kbdImage addGestureRecognizer:gestureRecogniser];

Upvotes: 1

Related Questions