UIViewController In-Call状态栏问题 [英] UIViewController In-Call Status Bar Issue

查看:158
本文介绍了UIViewController In-Call状态栏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

在通话状态栏消失后,模态显示的视图控制器不会向上移动,留下20px空/透明空间在顶部。

Modally presented view controller does not move back up after in-call status bar disappears, leaving 20px empty/transparent space at the top.

正常:无问题

待命:没有问题

在通话中消失后:

在顶部留出20px高的空/透明空间,在下面显示橙色视图。但是,状态栏仍然存在于透明区域上方。导航栏还为状态栏留出空间,其位置仅为20px太低。

Leaves a 20px high empty/transparent space at top revealing orange view below. However the status bar is still present over the transparent area. Navigation Bar also leaves space for status bar, its' just 20px too low in placement.


  • 基于iOS 10

  • 模态呈现的视图控制器

  • 自定义模式演示

  • 主视图控制器落后是橙色

  • 不使用Autolayout

  • 当旋转到风景时,20px In-Call Bar离开并仍然留下20px的差距。

  • 我选择退出在横向方向显示状态栏。 (即大多数股票应用程序)

  • iOS 10 based
  • Modally presented view controller
  • Custom Modal Presentation
  • Main View Controller behind is orange
  • Not using Autolayout
  • When rotated to Landscape, 20px In-Call Bar leaves and still leaves 20px gap.
  • I opt-out showing status bar in landscape orientations. (ie most stock apps)

我试着听App代表:

willChangeStatusBarFrame
didChangeStatusBarFrame

同时查看基于控制器的通知:

Also View Controller Based Notifications:

UIApplicationWillChangeStatusBarFrame
UIApplicationDidChangeStatusBarFrame

当我记录所有上述四种方法的呈现视图的帧时,帧始终位于(y:0)原点。

When I log the frame of presented view for all four above methods, the frame is always at (y: 0) origin.

查看控制器自定义模式演示文稿

    let storyboard = UIStoryboard(name: "StoryBoard1", bundle: nil)
    self.modalVC = storyboard.instantiateViewController(withIdentifier: "My Modal View Controller") as? MyModalViewController
    self.modalVC!.transitioningDelegate = self
    self.modalVC.modalPresentationStyle = .custom
    self.modalVC.modalPresentationCapturesStatusBarAppearance = true;
    self.present(self.modalVC!, animated: true, completion: nil)


    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        let containerView = transitionContext.containerView
        let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)
        let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)
        toViewController!.view.transform = CGAffineTransform(scaleX: 0.001, y: 0.001)

        UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0.0, options: [.curveEaseOut], animations: { () -> Void in

            toViewController!.view.transform = CGAffineTransform.identity

        }, completion: { (completed) -> Void in

           transitionContext.completeTransition(completed)

        })
 }


推荐答案

我也遇到过这个问题,但在我提出这个方法后,问题已经消失。

I faced this problem too but after I put this method, problem is gone.

iOS有默认方法 willChangeStatusBarFrame 用于处理状态栏。请把这个方法检查一下。

iOS has its default method willChangeStatusBarFrame for handling status bar. Please put this method and check it .

func application(_ application: UIApplication, willChangeStatusBarFrame newStatusBarFrame: CGRect) {
    UIView.animate(withDuration: 0.35, animations: {() -> Void in
        let windowFrame: CGRect? = ((window?.rootViewController? as? UITabBarController)?.viewControllers[0] as? UINavigationController)?.view?.frame
        if newStatusBarFrame.size.height > 20 {
            windowFrame?.origin?.y = newStatusBarFrame.size.height - 20
            // old status bar frame is 20
        }
        else {
            windowFrame?.origin?.y = 0.0
        }
        ((window?.rootViewController? as? UITabBarController)?.viewControllers[0] as? UINavigationController)?.view?.frame = windowFrame
    })
}

希望这件事可以帮到你。

谢谢

Hope this thing will help you.
Thank you

这篇关于UIViewController In-Call状态栏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆