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

AutoCompleteTableView loses user interaction when displayed over a sibling table cell #82

Open
robdigital opened this issue Aug 6, 2015 · 9 comments

Comments

@robdigital
Copy link

I'm using MLPAutoComplete TextFields in my project, in several textfields in dynamic table cells. It works perfectly when the cell's row is large enough to fit the entire AutoCompleteTableView (scrollable list of suggestions). However, if the row height is smaller than the auto suggestion window, the user interaction is not being picked up by the 'scrollable auto suggstion window' and instead of scrolling through the suggestions, it is making my tableview scroll.

I've played around with z indexes, bringing the textfield and autocomplete views to the front of super, which doesn't make any difference.

I've also tried setting EnableUserInteraction = NO on the tableview after the autocomplete is triggered, which only has the effect of making the scrollview unresponsive even though its own property of EnableUserInteraction is still set to YES.

I'm thinking that because I also use TPKeyboardAvoiding in my project, that it is somehow complicating the issue.

See the image of one example (it happens on all my views), in this particular example, the table has a header cell on top, then the following are dynamic cells. You can see in the image the hard black line (between tara and Clagary) that is the physical cutoff of the scrollability. i.e. touch above the line and autocomplete scrolls, touch below and whole table scrolls.

issuewithdropdown

Second picture to further detail working and broken interface.
issuewithdropdown2

And this also happens in the dynamic cells, not just header. Here is the next example.
issuewithdropdown3

@theoriginalgri
Copy link

To work around this, you can assign the autoCompleteParentView to the self.view (the parent of your UITableViewController) and change the autoCompleteTableOriginOffset to the mapped values. This might not work when scrolling is involved.

For example:

// Parent correction
textField.autoCompleteParentView = self.view;

// Offset correction
CGPoint pt = [textField convertPoint:CGPointMake(0, textField.frame.origin.y) toView:self.view];
textField.autoCompleteTableOriginOffset = CGSizeMake(0, pt.y);

@hamishcundy
Copy link

I'm having the same issue - however I can't find the autoCompleteParentView field. Are you sure thats the correct name?

@theoriginalgri
Copy link

OH! I am sorry!

One of our developers added this property and I did not check for that.

endiosGmbH@ef3243a

It might be good to prepare a pull request for that 😯

@zabolotiny
Copy link

Hi,
I have the same issue. After some investigation i have such info regarding the issue:

  1. This happens only when autolayout is active.
  2. Interaction is lost only on the part of the autocomplete table view
    http://prntscr.com/9h4jgy
    Unfortunately i can't find a solution :(
    Any suggestions to solve that problem?

@emartinson
Copy link

@theoriginalgri
Thank you!!! Your solution with parentView worked perfect!!!

@RyogaK
Copy link

RyogaK commented Feb 24, 2016

+1

@t4ec
Copy link

t4ec commented Jul 17, 2016

@theoriginalgri could you please merge the changes you mentioned regarding parentView? It would be great to have it by default in pod.

Thank you beforehand.

@pavankataria
Copy link

pavankataria commented Nov 21, 2016

@theoriginalgri @EddyBorja This still doesn't work for me... when I set the parent view to self.view, that is the tableview's superview, the bottom half of the autocomplete list still cannot accept touches other than the top half.. Could someone assist further please? Thank you

@ekhademi
Copy link

I have tried to solve a more general problem:
Problem: The autoCompleteTableView being outside of the parent view of the MLPAutoCompleteTextField, thus not responding to touch events.
Solution: Expanding the hittable area of MLPAutoCompleteTextField's parent view like described in this link (the hit test considers the autoCompleteTableView's boundaries):
https://stackoverflow.com/questions/11770743/capturing-touches-on-a-subview-outside-the-frame-of-its-superview-using-hittest
The Swift approach for the parent view looks something like this:

class MLPAutoCompleteTextFieldParentView: UIView {
    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        
        if clipsToBounds || isHidden || alpha == 0 {
            return nil
        }
        
        for subview in subviews.reversed() {
            let subPoint = subview.convert(point, from: self)
            if let result = subview.hitTest(subPoint, with: event) {
                return result
            }
        }
        
        return nil
    }
}

I have tested this approach when the MLPAutoCompleteTextField is inside a tableView.

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

No branches or pull requests

9 participants