Ios UIScrollView。如果contentOffset太大,就会出现奇怪的分页行为
Apple对Ios UIScrollView。如果contentOffset太大,就会出现奇怪的分页行为,ios,objective-c,uiscrollview,scroll-paging,Ios,Objective C,Uiscrollview,Scroll Paging,Apple对UIScrollView的分页在contentOffset.y大约10000000处有延迟,如果我们在contentOffset.y大约18900000处进行部分滑动,则不会返回原始状态。您可以使用代码mainView检查创建简单应用程序: @implementation MainView - (id) init { self = [super init]; if (self) { self.frame = [UIScreen mainSc
UIScrollView
的分页在contentOffset.y
大约10000000处有延迟,如果我们在contentOffset.y
大约18900000处进行部分滑动,则不会返回原始状态。您可以使用代码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
@实现主视图
-(id)init
{
self=[super init];
如果(自我)
{
self.frame=[UIScreen mainScreen].bounds;
UIScrollView*滚动=[UIScrollView新建];
scroll.frame=self.frame;
scroll.contentSize=(CGSize){CGRectGetWidth(self.bounds),20000000.0};
scroll.contentOffset=(CGPoint){0.018900000.0};
scroll.paginEnabled=是;
scroll.backgroundColor=[UIColor greenColor];
对于(浮动i=0;i<20000000.0;i+=500.0)
{
UIView*行=[UIView新建];
line.backgroundColor=[UIColor redColor];
line.frame=(CGRect){0,i,self.frame.size.width,30.0};
[滚动添加子视图:行];
}
[自添加子视图:滚动];
}
回归自我;
}
@结束
为什么会这样?有什么想法吗?在向Apple Bug Reporter报告后,它被修复了。在新版本的XCode中,您将看到一切都是正确的