UIScrollView doesn't scroll after upgrading to iOS7 / xcode 5

后端 未结 9 1954
抹茶落季
抹茶落季 2020-12-03 03:42

I have an app which in xcode 4.5 and ios 6.1 worked perfectly fine when scrolling. However, after downloading xcode 5 and iOS 7 my scroll views does not work anymore.???

9条回答
  •  一个人的身影
    2020-12-03 03:54

    I had the same issue after developing an app for iOS8, then testing on iOS7 afterwards. Although I had tried setting certain options on the scroll view such as:

    [self.scrollView setScrollEnabled:YES];
    [self.scrollView setContentSize:CGSizeMake(self.view.frame.size.width, 700)];
    [self.scrollView setContentOffset:CGPointZero];
    

    The solution that worked for me was to go into the storyboard file, and ensure that you have constraints set for all views within the scroll view. The scroll view's content size is calculated by the constraints of each subview within the scroll view, so in my case, I had a UIView and UITableView. After setting constraints for UIView (top, leading, trailing, height), and UITableView (vertical spacing to UIView, leading, trailing, bottom), the scroll view calculated the content size and started to function.

    While turning off Auto Layout does work, it's not an ideal solution for everyone. Just play around with Storyboard and set constraints for all subviews in the scroll view, so that a vertical line of constraints are set, from the top of the scroll view to the bottom.

提交回复
热议问题