开发者

Prevent subview from scrolling in a UIScrollView

开发者 https://www.devze.com 2023-01-02 18:28 出处:网络
I have a UIScrollView subclass with a certain subview I\'d like to prevent from scrolling (while all the other subviews scroll as normal).

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

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 (scrollvi开发者_StackOverflow社区ew) but it does not move as the user scrolls.

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


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


Add the view that you want not to move as a sibling view of the scroll view on top of the scroll view instead of as a subview.


You can set it's property called userInteractionEnabled to NO

0

精彩评论

暂无评论...
验证码 换一张
取 消