Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't click on suggestion #16

Closed
wiistriker opened this issue Oct 8, 2013 · 10 comments
Closed

can't click on suggestion #16

wiistriker opened this issue Oct 8, 2013 · 10 comments

Comments

@wiistriker
Copy link

I implement simple datasource for autocomplete list and show suggestions, but when i try to select one of the suggestion it do nothing.

I also try to implement some delegate methods like:

- (void)autoCompleteTextField:(MLPAutoCompleteTextField *)textField
  didSelectAutoCompleteString:(NSString *)selectedString
       withAutoCompleteObject:(id<MLPAutoCompletionObject>)selectedObject
            forRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"select: %@", selectedString);
}

Nothing happens.

http://s1.ipicture.ru/uploads/20131008/At8TrUtS.png

@akaru
Copy link

akaru commented Oct 10, 2013

I have the same problem. I think it's because using MLPAutocomleteTextField inside UITableView, so all touch events are intercepted by tableview.

@EddyBorja
Copy link
Owner

akaru has the right idea.

The problem is actually that the tableview of autocomplete suggestions is a subview of the UITableViewCell, but it lies outside the touchable area of the UITableViewCell, so it won't receive touch events, but it's still visible because the cell doesn't clip it's bounds.

A quick way to get around this problem is to not use the drop down style autocomplete table, instead use the keyboard accessory version.

@kevinseelbach
Copy link

I had the same problem, but I had forgot to set the field's delegate as itself, as in the example:

    self.autoCompleteField.delegate = self;
    self.autoCompleteField.autoCompleteDataSource = self;
    self.autoCompleteField.autoCompleteDelegate = self;

Whether it was a dropdown table or keyboard accessory didn't seem to make a difference.

@EddyBorja
Copy link
Owner

Are you saying you can't select items from the keyboard accessory either when the textfield is inside a tableview cell? If so, then that's the first time I've heard that issue.

@kevinseelbach
Copy link

I had a problem where the protocol method (which I copied from the demo) was not being called, but realized I forgot to set the delegates; I'm new to iOS but think that was my problem. The drop down appeared, the keyboard accessory appeared, but the NSLog statements were not called.


Sent from Mailbox for iPhone

On Thu, Nov 28, 2013 at 3:00 PM, Eddy Borja notifications@github.com
wrote:

Are you saying you can't select items from the keyboard accessory either when the textfield is inside a tableview cell? If so, then that's the first time I've heard that issue.

Reply to this email directly or view it on GitHub:
#16 (comment)

@bryanlogan
Copy link

Kevin, I'm seeing something similar. It started happening once I assigned the delegate for the MLPAutoCompleteTextField to the view controller (because I needed to do some stuff to handle the keyboard covering things up). Once I did this though, the UITableView doesn't receive the row selected event. The table does go away, but the field isn't updated.

I might be missing a [super] or something. I'll investigate more.

@mikumi
Copy link
Contributor

mikumi commented May 14, 2014

I think this issue has been fixed in #30 as well. The screenshot wiistriker has uploaded shows a UITableView.

@boazin
Copy link

boazin commented Apr 1, 2015

I seem to be having the same issue. Dropdown is not clickable when the textfield is inside a UITableViewCell - do I still have to use keyboard accessory?

@JeanMeche
Copy link

+1 I encounter the same problem when the textfield is in a UITableView (not a cell).

@jbiscarri
Copy link

I solved It by subclassing my UITableViewCell:

#import "AutoCompleteTableViewCell.h"

@interface AutoCompleteTableViewCell()
@property (nonatomic, assign) BOOL selectedCell;
@end

@implementation AutoCompleteTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectedCell = NO;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event
{
    UIView* hitView = [super hitTest:point withEvent:event];
    if (hitView != nil)
    {
        [self.superview bringSubviewToFront:self];
    }
    return hitView;
}

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent*)event
{
    CGRect rect = self.bounds;
    BOOL isInside = CGRectContainsPoint(rect, point);
    if(!isInside)
    {
        for (UIView *view in self.subviews)
        {
            isInside = CGRectContainsPoint(view.frame, point);
            if(isInside)
                break;
        }
    }
    if (!self.selectedCell) {
        self.selectedCell = YES;
        id view = [self superview];
        while (view && [view isKindOfClass:[UITableView class]] == NO) {
            view = [view superview];
        }
        UITableView *tableView = (UITableView *)view;
        NSIndexPath *indexPath = [tableView indexPathForCell:self];
        [tableView.delegate tableView:tableView didSelectRowAtIndexPath:indexPath];
    }
    return isInside;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants