Animate the keyboard in sync with the UIView while edge-swiping back in iOS7

前端 未结 3 581
攒了一身酷
攒了一身酷 2020-12-12 16:43

I\'d like to get the behavior similar to Messages app (also common in most texting apps) in iOS7, where in a conversation view swiping right from the left edge of the screen

3条回答
  •  暖寄归人
    2020-12-12 17:29

    It should just work automatically, but sometimes it doesn't because of some conditions.

    If the current firstResponder is located inside of active UIViewController and it dismiss throughout UINavigationController mechanism, the expected keyboard animation (horizontal) will be performed automatically. Therefore, sometimes this default behaviour is broken by other strange factors and the keyboard starts to disappear with slide-down animation instead of horizontal animation.

    I spent some days with debugging internal UIKit stuff (around methods needDeferredTransition, allowCustomTransition and other) to find one special factor that plays key role in my case.

    I discovered that the logic inside UIPeripheralHost checks frame of current UIViewConroller's view, frame of UINavigationController's view (container) and screen size and, if it all doesn’t equal each other, UIPeripheralHost decides that this current situation seems like modal window and sets flag allowCustomTransition = NO. That turn-off UINavigationController-specific horizontal animation.

    Fixing issue with frames completely solves my problem.

    If you are experiencing same problems, you can try to debug internal UIKit stuff around these private methods and find your conditions that turn off horizontal animation:

    https://github.com/JaviSoto/iOS8-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UIPeripheralHost.h

    https://github.com/JaviSoto/iOS8-Runtime-Headers/blob/master/Frameworks/UIKit.framework/_UIViewControllerKeyboardAnimationStyle.h

提交回复
热议问题