Swift UIScrollView does not scroll, but responds to setContentOffset and Delegate responds

Getting a really strange incident with a UIScrollView here that just refuses to scroll. I installed it in my StoryBoard and set contentSize correctly in my ViewDidLoad . I double-checked that it was Scrollable , etc., but it just doesn't work. I set scrollView.setContentOffset() and it scrolls great with great animation and calls the ScrollViewDidScroll delegate ScrollViewDidScroll . So, for any reason, why can't it scroll using drag and drop gestures?

Things I checked:
- UserInteraction Included on itself, all sub/superviews .
- Scrollable .
- Toggled: DelaysContentTouches and CancellableContentTouches .

I have no ideas. Currently using Xcode 6 Beta 1 . Any help would be appreciated.

Yours faithfully,
Mike

+6
source share
1 answer

This is not scrolling with drag and drop gestures due to auto-layout. The viewDidLoad will automatically reset the size of the content after it is defined. You have two options: you can turn off the automatic layout, or you can set contentSize to viewDidLayoutSubviews.

 override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() scrollView.contentSize = CGSize(width:10, height:10) } 
+22
source

Source: https://habr.com/ru/post/972047/


All Articles