将 UIScrollView 嵌套在 UIScrollView Cocoa Touch 中

发布于 2024-08-13 18:04:39 字数 726 浏览 6 评论 0原文

他们在这个线程中“刷”主题,但它并没有真正回答太多:Stackoverflow UIScrollView 问题

我有一个 UIScrollView 和一个 UIPageControl 一起工作来呈现一组视图。 (标准的“主屏幕”滑动样式,缺乏更好的词语)

滚动视图内的每个视图的底部都有一个薄菜单,也可以从一侧滑动到另一侧。如果有人还记得之前的 FaceBook 应用程序,它也有一个可以水平滑动的菜单,但是没有包含在另一个滚动视图中,但想法是相似的。 所以外层scrollView会滚动整个视图,包括包含内层scrollView的视图,但内层scrollView只会改变视图内部的一个菜单。

我已经对此进行了概念验证测试,发生的情况是,无论在屏幕上的哪个位置进行滑动,都会在两个滚动视图中调用委托方法,并且当从左向右滑动时,最里面的滚动视图将使应用程序崩溃,但是不是从右到左……

我有点感觉这是可以做到的,但我的做法是错误的。

有没有办法设置屏幕的哪个区域对滑动做出反应?即决定屏幕的上 3/4 将调用一组委托方法,而下 1/4 将调用另一组。 也许通过某种中介器在“处理”之前捕获滑动,然后确定哪个滚动视图应该做出反应?

希望有人能给我指出一个好的方向,谢谢:)

They "brush" the subject in this thread, but it does not really answer much:Stackoverflow UIScrollView question

I have a UIScrollView and a UIPageControl working together to present a set of views.
(Standard "Home screen" swipe style, in lack of better words)

Each of these views, inside the scrollView, has a thin menu in the bottom part, that can also be swiped from side to side. If anyone remember the previous FaceBook app, this also had a menu that could be swiped horizontally, however, not incased in another scrollView, but the idea is similar.
So the outer scrollView will scroll the entire view, including the view containing the inner scrollView, but the inner scrollView will only change a menu inside the view.

I already did a proof of concept test of this, what happens, is that delegate methods gets called in both the scrollViews no matter where on the screen the swipe takes place, and the innermost scrollView will crash the app when swiped left to right, but not right to left…

I sort of get the feeling that this can be done, but that Im going about it the wrong way.

Is there a way to set which area of the screen reacts to swipes? i.e. decide that the upper ¾ of the screen will call one set of delegate methods and the bottom ¼ will call another set.
Maybe through some sort of mediator that catches the swipes before they are "processed" and then determines which scrollView should react?

Hope someone can point me in a good direction on this one, thanks:)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

霓裳挽歌倾城醉 2024-08-20 18:04:39

解除滚动视图的嵌套怎么样?不要将滚动视图嵌入到另一个滚动视图中,而是使它们成为父 UIView 的同级兄弟姐妹。

不过,为了支持嵌套,我可以想到 App Store 应用程序,它可以让您水平滚动屏幕截图,同时垂直滚动应用程序描述。

What about de-nesting the scroll views? Instead of embedding a scrollview inside another scrollview, make them same-level siblings of a parent UIView.

In support of your nesting though, I can think of the App Store app which lets you scroll screen shots horizontally while the app description scrolls vertically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文