防止子视图在UIScrollView中滚动 [英] Prevent subview from scrolling in a UIScrollView

查看:111
本文介绍了防止子视图在UIScrollView中滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIScrollView 子类与某个子视图我想防止滚动(当所有其他子视图滚动正常)。

I have a UIScrollView subclass with a certain subview I'd like to prevent from scrolling (while all the other subviews scroll as normal).

我可以想到的最接近的例子是 UITableView 的右边的索引条(查看联系人应用程序参见示例)。我猜这是一个子视图的表(scrollview),但它不会随着用户滚动移动。

The closest example to this I can think of is UITableView's "index strip" on the right side (look in the Contacts app to see an example). I am guessing this is a subview of the table (scrollview) but it does not move as the user scrolls.

我似乎不能让我的子视图保持放!

I can't seem to make my subview stay put! How can I accomplish this?

推荐答案

诀窍是调整非滚动子视​​图的框架 -layoutSubviews

The trick is to adjust the frame of the "non-scrollable" subview inside -layoutSubviews.

这篇关于防止子视图在UIScrollView中滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆