- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
在启用旁白的情况下, 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/
C# 程序: short a, b; a = 10; b = 10; a = a + b; // Error : Cannot implicitly convert type 'int' to 'sh
这个问题已经有答案了: Promotion in Java? (5 个回答) 已关闭10 年前。 我有三个短变量。当我将两个相加并将结果分配给第三个时,Eclipse 告诉我需要将其转换为 Short
我正在开展一个项目,我需要获取一系列带符号的 16 位整数、负值和正值,并将它们发送到函数以在单元测试期间进行分析。 由于不同的原因,该函数仅采用无符号 16 位整数数组,因此我需要将有符号整数存储在
这个问题在这里已经有了答案: Implicit type promotion rules (4 个答案) 关闭 3 年前。 有如下代码: short a = 5; short b = 15; sho
我有以下代码: var v = [0xFF, 0xFF]; alert((v[0]> 16); 16位左移将所有位向左移动;算术 16 位右移在移位时处理符号。 (Javascript 使用 32 位
我正在尝试尽可能多地挤出我的内存。我有一个 4.9999995e13 整数矩阵,但它们只需要为真或假 - 基本上我只需要为这些整数中的每一个存储一位。 我知道 C 中没有单个位类型(也许有人可以向我解
这个问题已经有答案了: Different between parseInt() and valueOf() in java? (11 个回答) 已关闭 5 年前。 我最近偶然发现了another q
当我将相同的值分配给有符号和无符号的 short 并进行比较时,它失败了,但它适用于 int。除非我强制转换一个或另一个使它们成为相同的类型,否则比较不起作用。 #include int main()
所以我试图解释以下输出: short int v = -12345; unsigned short uv = (unsigned short) v; printf("v = %d, uv = %u\n
当我将相同的值分配给有符号和无符号的 short 并进行比较时,它失败了,但它适用于 int。除非我强制转换一个或另一个使它们成为相同的类型,否则比较不起作用。 #include int main()
这个问题在这里已经有了答案: What is the 'short' data type in C? (1 个回答) 关闭 7 年前。 将变量声明为 short int 和 short 有什么区别?
C 中的 short int 包含 16 位,第一位表示该值是负数还是正数。我有一个 C 程序如下: int main() { short int v; unsigned short
Short.parseShort(String s, int radix) 存在,Integer.parseInt(String s, int radix) 和 Long.parseLong(Stri
我想我可以从 this question 推断出来但我不能 我当然可以 short[] shortarray = {0,1,2}; List shortList = new ArrayList();
这个问题在这里已经有了答案: char and the usual arithmetic conversion rules (5 个答案) 关闭 6 年前。 假设 int 是 16 位类型,以防止从
到目前为止我已经试过了,但我仍然在下面的代码中遇到错误: #include typedef unsigned short unichar; typedef const unichar unimap_t
unsigned short int 和 c 中的 unsigned short decleration 之间有区别吗?如果有,那是什么?我尝试在网上查找,但找不到任何有值(value)的东西。 un
我有数据库,由于与另一位开发人员混淆,我需要在一个表中更改列的值。我有一个名为 credits 的表和一个名为 credit_type 的列。 credit_type 有 2 个值 long 和 sh
我在 JNI hell 中进行类型转换: 这是一般的流程: 读取一个文件,它返回一个一维 float 组。 转换这些floats[] 到 shorts[](*4095,我想要一个12位数字) 将这些短
我正在尝试优化两个 c 样式数组的点积,这些数组的大小为 contant 和 small,类型为 short。 我已经阅读了一些关于 SIMD 内在函数的文档以及许多关于使用此内在函数进行点积优化的博
我是一名优秀的程序员,十分优秀!