Apple的分页UIScrollView
在大约 10000000 处有延迟,contentOffset.y
如果我们将在大约 18900000 处进行部分滑动,请不要回到原始状态。contentOffset.y
您可以使用以下代码创建简单的应用程序来检查它mainView
:
@implementation MainView
- (id) init
{
self = [super init];
if (self)
{
self.frame = [UIScreen mainScreen].bounds;
UIScrollView *scroll = [UIScrollView new];
scroll.frame = self.frame;
scroll.contentSize = (CGSize){ CGRectGetWidth(self.bounds), 20000000.0 };
scroll.contentOffset = (CGPoint){ 0.0, 18900000.0 };
scroll.pagingEnabled = YES;
scroll.backgroundColor = [UIColor greenColor];
for (float i = 0; i < 20000000.0; i += 500.0)
{
UIView *line = [UIView new];
line.backgroundColor = [UIColor redColor];
line.frame = (CGRect){ 0, i, self.frame.size.width, 30.0 };
[scroll addSubview:line];
}
[self addSubview:scroll];
}
return self;
}
@end
为什么会发生?有任何想法吗?