Iphone CGRectOffset导致刷卡方式错误

Iphone CGRectOffset导致刷卡方式错误,iphone,ios,uiscrollview,frame,cgrect,Iphone,Ios,Uiscrollview,Frame,Cgrect,试图刷走一个单元格,就会出现另一个视图。这是到目前为止我的代码,但我无法看到rightView。相反,它限制了我看到leftView(我想要相反的…leftView甚至不存在)。与CGRects和cgrectoffset非常混淆。如果你能纠正我的代码,那就太好了。谢谢 - (void)layoutSubviews { [super layoutSubviews]; CGRect frame = self.bounds; self.scrollView.frame = frame; self.s

试图刷走一个单元格,就会出现另一个视图。这是到目前为止我的代码,但我无法看到rightView。相反,它限制了我看到leftView(我想要相反的…leftView甚至不存在)。与CGRects和cgrectoffset非常混淆。如果你能纠正我的代码,那就太好了。谢谢

- (void)layoutSubviews
{
[super layoutSubviews];

CGRect frame = self.bounds;
self.scrollView.frame = frame;
self.scrollView.contentSize = CGSizeMake(frame.size.width*2, frame.size.height);

self.centerView.frame = CGRectOffset(frame, frame.size.width, 0);
self.rightView.frame = CGRectOffset(frame, frame.size.width*2, 0);

[self.scrollView scrollRectToVisible:self.centerView.frame animated:NO];
[self.scrollView setUserInteractionEnabled:YES];
self.scrollView.scrollEnabled = YES;
}

您正在将centerView和rightView的偏移分别设置为
frame.size.width
frame.size.width*2
。您需要的是中心为
0
,右视图为
frame.size.width


您只是将视图移动过多,因此左侧的
帧.size.width
像素数没有视图。

您正在将centerView和rightView的偏移量分别设置为
frame.size.width
frame.size.width*2
。您需要的是中心为
0
,右视图为
frame.size.width

您只是将视图移动了太多,因此左侧的
frame.size.width
像素数没有视图