@@ -242,7 +242,7 @@ - (UIAccessibilityElement *)accessibilityElementMatchingBlock:(BOOL(^)(UIAccessi
242
242
}
243
243
244
244
UITableView *tableView = (UITableView *)self;
245
- __block NSIndexPath *firstIndexPath = nil ;
245
+ CGRect initialPosition = CGRectMake (tableView. contentOffset . x , tableView. contentOffset . y , tableView. frame . size . width , tableView. frame . size . height ) ;
246
246
247
247
// Because of a bug in [UITableView indexPathsForVisibleRows] http://openradar.appspot.com/radar?id=5191284490764288
248
248
// We use [UITableView visibleCells] to determine the index path of the visible cells
@@ -252,13 +252,9 @@ - (UIAccessibilityElement *)accessibilityElementMatchingBlock:(BOOL(^)(UIAccessi
252
252
if (indexPath) {
253
253
[indexPathsForVisibleRows addObject: indexPath];
254
254
}
255
- if (!firstIndexPath || ([firstIndexPath compare: indexPath] == NSOrderedDescending)) {
256
- firstIndexPath = indexPath;
257
- }
258
255
}];
259
256
260
- BOOL animationEnabled = [KIFUITestActor testActorAnimationsEnabled ];
261
- CFTimeInterval delay = animationEnabled ? 0.5 : 0.05 ;
257
+ CFTimeInterval delay = 0.05 ;
262
258
for (NSUInteger section = 0 , numberOfSections = [tableView numberOfSections ]; section < numberOfSections; section++) {
263
259
for (NSUInteger row = 0 , numberOfRows = [tableView numberOfRowsInSection: section]; row < numberOfRows; row++) {
264
260
if (!self.window ) {
@@ -270,21 +266,15 @@ - (UIAccessibilityElement *)accessibilityElementMatchingBlock:(BOOL(^)(UIAccessi
270
266
if ([indexPathsForVisibleRows containsObject: indexPath]) {
271
267
@autoreleasepool {
272
268
// scroll to the last row of each section before continuing. Attemps to ensure we can get to sections that are off screen. KIF tests (e.g. testButtonAbsentAfterRemoveFromSuperview) fails without this line. Also without this... we can't expose the next section (in code downstream)
273
- [tableView scrollToRowAtIndexPath: [indexPathsForVisibleRows lastObject ] atScrollPosition: UITableViewScrollPositionNone animated: animationEnabled ];
269
+ [tableView scrollToRowAtIndexPath: [indexPathsForVisibleRows lastObject ] atScrollPosition: UITableViewScrollPositionNone animated: NO ];
274
270
continue ;
275
271
}
276
272
}
277
273
278
- // expose the next section (unless it's a UIPicker View).
279
- if (subViewName && ![subViewName containsString: @" UIPicker" ] )
280
- {
281
- CGRect sectionRect = [tableView rectForSection: section];
282
- [tableView scrollRectToVisible: sectionRect animated: NO ];
283
- }
284
-
285
274
@autoreleasepool {
286
275
// Scroll to the cell and wait for the animation to complete. Using animations here may not be optimal.
287
- [tableView scrollToRowAtIndexPath: indexPath atScrollPosition: UITableViewScrollPositionNone animated: animationEnabled];
276
+ CGRect sectionRect = [tableView rectForRowAtIndexPath: indexPath];
277
+ [tableView scrollRectToVisible: sectionRect animated: NO ];
288
278
289
279
UITableViewCell *cell = [tableView cellForRowAtIndexPath: indexPath];
290
280
UIAccessibilityElement *element = [cell accessibilityElementMatchingBlock: matchBlock notHidden: NO ];
@@ -300,13 +290,13 @@ - (UIAccessibilityElement *)accessibilityElementMatchingBlock:(BOOL(^)(UIAccessi
300
290
return [self accessibilityElementMatchingBlock: matchBlock];
301
291
}
302
292
}
303
- if (firstIndexPath) {
304
- [tableView scrollToRowAtIndexPath: firstIndexPath atScrollPosition: UITableViewScrollPositionTop animated: NO ];
305
- }
293
+
306
294
// if we're in a picker (scrollView), let's make sure we set the position back to how it was last set.
307
295
if (scrollView != nil && scrollContentOffset.x != -1.0 )
308
296
{
309
297
[scrollView setContentOffset: scrollContentOffset];
298
+ } else {
299
+ [tableView scrollRectToVisible: initialPosition animated: NO ];
310
300
}
311
301
CFRunLoopRunInMode (UIApplicationCurrentRunMode, delay, false );
312
302
} else if ([self isKindOfClass: [UICollectionView class ]]) {
0 commit comments