UIViewController custom transition stuck on iOS13

前端 未结 4 2072
长发绾君心
长发绾君心 2021-02-05 11:42

I\'ve implemented a custom transition between two view controllers in my iOS app and it worked fine with iOS 10, 11, and 12.

Now I want make it ready for iOS 13 using Xc

4条回答
  •  佛祖请我去吃肉
    2021-02-05 12:01

    TL;DR

    This is a bug in iOS, but you can use context.viewController(forKey:.from).view as a workaround.

    Full Details

    This appears to be a bug in iOS 13.0. As of iOS 13.1 beta 3, it's still there as well. http://www.openradar.me/radar?id=4999313432248320

    The transition context's view(forKey:) method is incorrectly returning nil under certain circumstances. It appears this is happening for view(forKey: .from) when the presenting view controller is being presented non-modally. When dismissing a view controller that was originally presented from a non-modal view controller, the result of view(forKey: .to) is also nil.

    I've observed this not only on the new sheet-style presentation on iPhone, but also in normal form sheets and popovers on iPad.

    Another manifestation of this issue seems to be that the finalFrame(for:) method returns an incorrect CGRect when asked what the final frame for this view controller should be. In my testing, it is returning a full-screen rect, even though the correct view is smaller.

    A workaround is to use the root view controller of view controller returned by viewController(forKey:) method, although the documentation explicitly discourages that: "The view returned by this method may or may not be the root view of the corresponding view controller."

提交回复
热议问题