- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试滑动一个单元格,另一个 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.width
和 frame.size.width*2
。您希望中心为 0
,右 View 为 frame.size.width
。
您只是将 View 移得太多,所以左边的 frame.size.width
像素数没有 View 。
关于iphone - CGRectOffset 导致滑动方向错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18140238/
尝试滑动一个单元格,另一个 View 就会出现。到目前为止,这是我的代码,但我看不到 rightView。相反,它限制了我看到 leftView(我想要相反的......leftView 甚至不存在)
不确定这是否与我的问题有关,但我有一个动画序列可以移动 UIView使用以下代码超出框架: [UIView animateWithDuration:0.3
我有一个名为 containerView 的 UIView。 我将其作为 subview 添加到 Controller View 的 Root View 中。我以编程方式向它添加了一些约束(我将其居中
我知道这没有任何意义,但我在使用核心数据构建并调用 CGRectOffset 的 iPhone 应用程序中遇到了一个非常奇怪的错误。我的 App Delegate 的 didFinishLaunchi
我是一名优秀的程序员,十分优秀!