开发者

UIScrollView changes content offset on presentModalViewController

开发者 https://www.devze.com 2023-04-07 23:40 出处:网络
A UIScrollView in my view hierarchy is acting funky whenever I present a modal view controllerabove it. It automatically adjusts the content offset and moves my content down about 40 pixels. I can\'t

A UIScrollView in my view hierarchy is acting funky whenever I present a modal view controller above it. It automatically adjusts the content offset and moves my content down about 40 pixels. I can't seem to figure out how to stop this.

After snooping around I've found that the presentModalViewController somehow triggers the 开发者_C百科private method _adjustContentOffsetIfNecessary on my UIScrollView and this is what is changing the offset.

Any idea if this is a bug on Apple's part? Or is something getting set screwy in my UIScrollView? Anyway to disable this _adjustContentOffsetIfNecessary method or at least this side effect?


Although it is not fancy, I solved this resetting the content offset in the viewDidAppear of the presentingViewController.


Try setting the property automaticallyAdjustsScrollViewInsets of your ViewController, that contains the UIScrollView, to "NO"

0

精彩评论

暂无评论...
验证码 换一张
取 消