简体   繁体   中英

ScrollsToTop not working on iOS 7

I have a UITextView inside of a UITableView . In the code, I set textView.scrollEnabled = NO;

When I run the project on iOS6, I can scroll to the top when I press to the status bar. However, when I run the project in iOS7, I could not manage to scroll top when it is pressed to the status bar. Could you please help me to solve the issue?

The correct property you should be using is:

textView.scrollsToTop = NO;

When you click the status bar, it will search throughout your views for UIScrollViews with that property as YES and scroll it to top.

I think that on iOS7 if there is more than one scrollView with that property as YES it will not do anything. So you need to set it to NO on all you don't want the behavior and just leave it as YES on the tableView if that is what you want to scroll on status bar touch.

UITextView and UITableView are both subclasses of UIScrollView so they all inherit that property and behavior. By default, all of them have it as YES (if I'm not mistaken).

It is a good solution for iOS 7 : http://ruiaureliano.tumblr.com/post/37260346960/uitableview-tap-status-bar-to-scroll-up

It worked in my project.

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