iPhone SDK UIScrollView 移动后没有得到触摸事件
我对 UIScrollView 进行子类化,并在开始时用一些项目填充此 ShowsScrollView。填充后,我将框架和内容大小设置为此 ShowsScrollView。现在一切正常,我收到触摸事件,滚动正在工作。
但是在旋转到横向后,我更改 ShowsScrollView 框架的 x 和 y 坐标,将其从下角移动到右上角。然后我调整它的大小(更改 ShowsScrollView 框架的宽度和高度)并重新排序此滚动中的项目。最后我设置了新的 contentSize。 现在我仅在滚动视图的前 1/4 上获得触摸事件,滚动也仅在滚动视图的 1/4 上起作用,但滚动滚动视图中的所有项目。 在所有操作之后,我写了一个日志: NSLog(@"ViewController: setLandscape finish: size: %f, %f content: %f,%f",scrollView.frame.size.width,scrollView.frame.size.height,scrollView .contentSize.width,scrollView.contentSize.height );
值是正确的: ViewController: setLandscape finish: size: 390.000000, 723.000000 content: 390.000000,950.000000
在旋转回纵向时,我将所有东西移回并调整大小,一切正常..
请帮忙!
I'm subclassing UIScrollView and on the start I fill this ShowsScrollView with some items. After filling it, I setup frame and contentSize to this ShowsScrollView. Everything works fine for now, i get touches events, scrolling is working..
But after rotation to landscape, I change x and y coordinates of ShowsScrollView frame, to move it from bottom to top right corner. Then I resize it (change width and height of ShowsScrollView frame) and reorder items in this scroll. At the end I setup new contentSize.
Now i get touches event only on first 1/4 of scrollview, scrolling also work only on 1/4 of scrollview, but scroll all items in scrollview.
After all actions I write a log: NSLog(@"ViewController: setLandscape finished: size: %f, %f content: %f,%f",scrollView.frame.size.width,scrollView.frame.size.height, scrollView.contentSize.width, scrollView.contentSize.height );
Values are correct:
ViewController: setLandscape finished: size: 390.000000, 723.000000 content: 390.000000,950.000000
On rotating back to portrait, I move and resize all thing back and everything works fine..
Please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,并在更改滚动视图的框架后再次设置 self.view 的大小,设法使其正常工作。我不知道为什么会这样,但确实如此。
I had the same issue and managed to get it working by setting the size of self.view again AFTER changing the scrollview's frame. I don't know why this works, but it does.
您必须将
scrollView
带到superView
的前面,例如:You have to bring
scrollView
to front of thesuperView
, for example: