简体   繁体   中英

willSelectRowAtIndexPath, didSelectRowAtIndexPath are not calling in iphone when using touches began method and performselector

I am developing an application, in which one of the screen i am using have tableview, it is tableview controller. i have written custom touchesbegan,touchesmoved,touchesended methods insside a tableview controller class, when ever user presses on any cell touchesbegan method is calling and withing this to detect long tap what i did was

[self performSelector:@selector(longTap) withObject:nil afterDelay:1.0];

if user removes his finger before 1sec, in touchesmoved and touchesended methods i am canceling the performselector .

now what happens is when i press & hold for 1min longTap method is calling and willSelectRowAtIndexPath , didselectRowAtIndexPath are not calling. but i need to get the indexpath.row value before performing any action on longTap method.
Can any one help me on this issue. please share your valuable suggestions.

Thanks in advance.

You should consider using a gesture recognizer like UILongPressGestureRecognizer . Fiddling with the touch events yourself is hard and error prone.

It is very easy to break a flow of events that UIKit classes depends upon to function. Gesture recognizers is the public API for hooking into the touch event flow, in simple and advanced easy, without breaking UIKit functionality.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM