键盘视图使用UIViewControllerTransitioningDelegate搞乱了Modally呈现的视图

时间:2014-12-01 14:56:26

标签: ios objective-c uitableview ios7 swift

我使用UIViewControllerTransitioningDelegate实例作为transitioning delegate and modalPresentationStyle = Custom来呈现来自他人的视图。 我正在使用TableViewController使用内部带有UITextfields的静态表格视图单元格。现在,当点击边框靠近键盘框架的文本字段时,键盘下方的tableView部分会显示出来。我还删除了我添加到半透明背景中的UITapGestureRecognizer,以确保它不是问题的一部分,但问题仍然存在。有任何想法吗?以下是animateTransition()方法

  func animateTransition(transitionContext: UIViewControllerContextTransitioning) {

dimmingView.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
let containerView = transitionContext.containerView()
if let presentedViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) {

    let presentedView = presentedViewController.view
    let fromView = transitionContext.viewForKey(UITransitionContextFromViewControllerKey)
    let centre = presentedView.center

    if isPresenting {

        presentedView.center = containerView.center
        presentedView.frame = presentedView.bounds.rectByInsetting(dx: 30, dy: 150)

        transitionContext.containerView().addSubview(presentedView)

        dimmingView.frame = containerView.bounds
        dimmingView.alpha = 0.0
        containerView.insertSubview(dimmingView, atIndex: 0)

        presentedViewController.transitionCoordinator()?.animateAlongsideTransition({
            context in
            self.dimmingView.alpha = 1.0
            }, completion: nil)

    }
    else {
        presentedViewController.transitionCoordinator()?.animateAlongsideTransition({
            context in
            self.dimmingView.alpha = 0.0
            }, completion: {
                context in
                self.dimmingView.removeFromSuperview()
        })
    }



    UIView.animateWithDuration(self.transitionDuration(transitionContext),
        delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 10.0, options: nil,
        animations: {
            presentedView.center = centre
        }, completion: {
            _ in
            transitionContext.completeTransition(true)
    })
}

}

enter image description here

0 个答案:

没有答案