gpt4 book ai didi

iOS 8.4 : Scroll view resets contentOffset with Voice Over enabled shortly after view appear

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:12:58 25 4
gpt4 key购买 nike

在启用旁白的情况下, ScrollView 会在 View 出现后一秒重置其预设的 contentOffset。它发生在 iOS 8.4 设备上,9.0 没有重现。看起来一些内部 UIScrollViewAccessibility 代码强制 ScrollView 到 setContent: 当成为焦点时为零。没有找到任何方法来规避这一点。

有什么想法吗?

相关代码示例说明了该错误。只需创建一个带有 Collection View 的 View ,创建一个重用 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

最佳答案

这是故意的。如果用户使用滑动手势进行导航。如果您导航到 ScrollView ,则应聚焦 View 中的第一个元素。对于有视力的 VoiceOver 用户,显然不向上滚动到顶部会很不协调,因为您的焦点矩形可能不在屏幕上。这是一项功能,而不是错误。

关于iOS 8.4 : Scroll view resets contentOffset with Voice Over enabled shortly after view appear,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34793175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com