1
使用Voice Over啓用的滾動視圖在視圖確實出現後重置其預設內容一秒鐘。它發生在iOS 8.4設備上,9.0沒有複製。聚焦時,看起來內部UIScrollViewAccessibility
代碼強制滾動視圖到setContent:
爲零。沒有找到任何方法來逃避這一點。iOS 8.4:滾動視圖重置contentOffset,在視圖出現後立即啓用Voice Over
有什麼想法?
相關代碼示例說明了該錯誤。 只需使用集合視圖創建視圖,使用重用ID「單元格」創建單元格並在其上放置標籤。
@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
那麼,如果這是一個功能,那麼爲什麼它在iOS 9.x中不存在?當再次獲取焦點時,它也不會滾動到開始位置,只會在第一個視圖出現 – markov
作爲禁用用戶,您不希望每次都發生這種情況。如果您將焦點從視圖中移除並回來,您會期望視圖成爲您留下的視圖(請參閱WCAG 2.0)。功能從操作系統變爲操作系統。否則就不會有9.x. – ChrisCM