Anyone has ever come into the problem that UITableView
need long press to trigger the didSelectRowAtIndexPath
method?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
I had exactly the same trouble :
My solution to select a cell in Table View by a short tap (press) :
If you have used any gesture recognizer try to removing it and check if it causing the problem or not ?
Other wise
Not sure but The problem might be in the
UITableView
hasdelaysContentTouches
turned ON. Turn this OFF so touches get through to the cells faster.You have to add UILongPressGesture to your cell's view and on fire just call didSelectRowAtIndexPath (better will be to call another method - not standard UITableViewDelegate's method) from your class that adopts UITableViewDelegate.
I will suggest You create own protocol, inherited from UITableViewDelegate, add there method for long press behavior method and enjoy. Something similar to:
Your delegate in this case would adopt not standard UITableViewDelegate, but this one. Also You have to create own cell (inherited from UITableViewCell) and add there delegate property (id ) that will be used when long press fired.
Also there can be situation that standard didSelectRowAtIndexPath will be fired before your long press will fire, so I suggest you to disable standard selection behavior for table view:
In my situation I had a UITapGestureRecognizer on my view for hiding my keyboard.
This solved the problem: