简体   繁体   中英

UIScrollView moves on its own

I have a full screen UIScrollView that has several possible layout configurations. It is basically a "contact" card eith some buttons, imageViews, Labels , and text fields. When it loads, buttons will be moved or removed based on the content available.

Oddly, the Scorll View does not always start in the same position. Sometimes it loads with the top in view, other times the bottom or all points in between. It seems random. I have 2 contacts that trigger the exact same full layout but yet the Scroll View starts differently for both. Also each contact does act the same, the same contact puts the scroll view in the same position.

Anyone know where to start? I would like the scroll view to always start at the beginning.

This is happening to me a lot. It was puzzling, and we narrowed it down to a function that changes a UITextView. Anyway, UIKit: UIScrollView automatically scrolling when a subview increases its width past the edge of the screen

UITextViews inside modal views (scrollers) implement similar behavior. So I refined my search a bit and found that answer.

Now to email Apple and kindly ask their devs why it doesn't check to see if it's in a modal, or if a user's tapping the UITextView before deciding it should scroll on its own with a private call, making circumvention cause "special case" band-aids (as of iOS 5.1)

Set the scrollView content offset after you're done adding objects.

[setContentOffset:CGPointMake(0,0) animated:NO]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM