启用 Voice Over 后,滚动视图会在视图出现后一秒重置其预设 contentOffset。它发生在 iOS 8.4 设备上,9.0 不会重现。看起来有些内在UIScrollViewAccessibility
codeforces 滚动视图到setContent:
当变得专注时为零。没有找到任何方法来逃避这一点。
有什么想法吗?
相关代码示例说明了该错误。
只需创建一个带有集合视图的视图,创建一个具有重用 id“Cell”的单元格并在其上放置一个标签。
@interface ViewController () <UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>
@property (nonatomic, weak) IBOutlet UICollectionView *collectionView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.collectionView.backgroundColor = [UIColor clearColor];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.collectionView reloadData];
//set there 4 seconds and bug will disappear
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:5 inSection:0] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO];
});
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
NSLog(@"Why you scroll second time?");
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return self.view.bounds.size;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 10;
}
- (UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
UILabel *label = (UILabel*)cell.contentView.subviews[0];
label.text = @(indexPath.item + 1).stringValue;
if (indexPath.item == 5) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, label);
});
}
return cell;
}
@end
它是故意这样做的。如果用户使用滑动手势进行导航。如果导航到滚动视图,则视图中的第一个元素应该获得焦点。对于视力正常的 VoiceOver 用户来说,显然不向上滚动到顶部会感到不舒服,因为您的焦点矩形可能会超出屏幕。这是一个功能,而不是一个错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)