Intro
I have UIPanGestureRecognizercreated like this:
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
[panRecognizer setCancelsTouchesInView:NO];
[self.view addGestureRecognizer:panRecognizer];
and tableView with NSTimer that fires every 0.3 s to insert new row to tableView if new data appears in database.
Creation of NSTimer :
NSTimer* timer = [NSTimer timerWithTimeInterval:0.3 target:self selector:@selector(onTick:) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
Inside onTick selector if new data appeared I perform simple row insertion:
[_tableView beginUpdates];
[_tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationTop];
[_tableView endUpdates];
The tableView has disabled scrolling and user interaction.
Issue
Calling [_tableView insertRowsAtIndexPaths:]makes UIPanGesureRecognizer unable to register any new touch event (panning and tapping). If I start to pan and then begin to add rows the panning doesn't break. I just can't start panning while rows are being added.
Things I tried and facts
- Calling
insertRowsAtIndexPathsin background using GCD doesn't work and also causes serious issues with in my app - cells are created very fast so it's not a performance issue
- Starting to pan before inserting rows and then adding new cells doesn't make the panning choppy, the movement is still very smooth
- Changing row animation to
UITableViewRowAnimationNonedoes nothing
Does anyone know why it happens and how to fix it?