我的PSWSnapshotView最终在_scrollView(40px偏移)内向右移得太远了。然而,它们的框架设置为第一个在(0,0),但第一个显示在(snapshotInset,0)而不是:/。
- (void)layoutViews
{
CGRect frame = self.frame;
CGFloat pageWidth = frame.size.width - (snapshotInset * 2);
CGRect pageFrame = CGRectMake(0.0f, 0.0f, pageWidth, frame.size.height);
NSInteger pageCount = [applications count];
[pageControl setNumberOfPages:pageCount];
[scrollView setFrame:CGRectMake(snapshotInset, 0.0f, pageWidth, frame.size.height)];
[scrollView setContentSize:CGSizeMake((pageWidth * pageCount) + 1.0f, frame.size.height)];
for (int i = 0; i < pageCount; i++) {
PSWSnapshotView *view;
if ([snapshotViews count] <= i)
{
PSWSnapshotView *view = [[PSWSnapshotView alloc] initWithFrame:pageFrame application:[applications objectAtIndex:i]];
view.delegate = self;
[scrollView addSubview:view];
[snapshotViews addObject:view];
[view release];
}
else
{
view = [snapshotViews objectAtIndex:i];
[view setFrame:pageFrame];
}
pageFrame.origin.x += pageWidth;
}
}
self.frame.size.width = 320; self.frame.size.height = 370; snapshotInset = 40; [申请数] = 2;
所有尺寸和框架都设置正确(我用NSLog检查过)。
答案 0 :(得分:0)
您是否可以在某处设置scrollView.contentOffset,与此无关?此外,这可能只是一个复制/粘贴问题,您同时引用snapshotInset和_snapshotInset。