简体   繁体   中英

UIScrollView doesn't respond to scrollRectToVisible:animated: called from ViewDidLoad in iOS 5

The main view (the one shown at launch) for my application is an UIScrollView that contains an UIView. To organize my nibs I'm using this method and everything works fine.

However, when calling scrollRectToVisible:animated in ViewDidLoad in the main view controller (having already set the scrollView's content size) the scrollView doesn't scroll to the indicated CGRect.

There are two strange factors to consider:

  1. The scrollView scrolls as expected on iOS 6 (the problem exposed presents itself on iOS 5).

  2. If I call the code to scroll with a 2 sec delay the scroll happens.

Call the scrollRectToVisible:animated in the viewDidAppear:(BOOL)animated.

I solved the same problem with this.

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