gpt4 book ai didi

iphone - CGRectOffset 导致滑动方向错误

转载 作者:行者123 更新时间:2023-11-29 13:07:58 27 4
gpt4 key购买 nike

尝试滑动一个单元格,另一个 View 就会出现。到目前为止,这是我的代码,但我看不到 rightView。相反,它限制了我看到 leftView(我想要相反的......leftView 甚至不存在)。对 CGRects 和 CGRectOffsets 很困惑。如果您能更正我的代码,那就太好了。谢谢。

- (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.widthframe.size.width*2。您希望中心为 0,右 View 为 frame.size.width

您只是将 View 移得太多,所以左边的 frame.size.width 像素数没有 View 。

关于iphone - CGRectOffset 导致滑动方向错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18140238/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com