Skip to content

Pushing UIViewController from SideMenu sometimes blinks/flashes This bugs has no fix at 6.5.0  #694

Open

Description

@northcity

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at:indexPath,动画:true)
let starVc = TDViewController()
starVc.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(starVc,动画:true)
}
当我从侧栏的页面中didseleted方法中push一个新页面,这样做会出现闪烁。类似有个黑色的遮罩遮住了页面零点几秒,在不同的页面之前push时发生概率大点。每次App重新运行后也可以复现,但当我推了几次页面后,这个问题就自己消失了。

Activity

  1. northcity commented on Jul 7, 2022

    @northcity
    Author

    navigationController?.dismiss(动画:false)
    let starVc = TDViewController()
    starVc.hidesBottomBarWhenPushed = true
    navigationController?.pushViewController(starVc,动画:true)

    这样写可以解决问题,但觉得不是很对。

  2. viihua commented on Dec 20, 2022

    @viihua

    image
    可以尝试下这样设置,然后在pushViewController后手动调用下dismiss

  3. Kedar-27 commented on Apr 17, 2023

    @Kedar-27

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at:indexPath,动画:true)
    let starVc = TDViewController()
    starVc.hidesBottomBarWhenPushed = true
    navigationController?.pushViewController(starVc,动画:true)
    }
    当我从侧栏的页面中didseleted方法中push一个新页面,这样做会出现闪烁。类似有个黑色的遮罩遮住了页面零点几秒,在不同的页面之前push时发生概率大点。每次App重新运行后也可以复现,但当我推了几次页面后,这个问题就自己消失了。

    +1

  4. Dreamer4ik commented on Apr 25, 2023

    @Dreamer4ik

    It works for me version 6.5.0
    Add

    extension UINavigationController { func pushViewController(_ viewController: UIViewController, animated: Bool = true, completion: (() -> Void)? = nil) { CATransaction.begin() CATransaction.setCompletionBlock(completion) viewController.view.backgroundColor = .white pushViewController(viewController, animated: animated) CATransaction.commit() } }

    Set
    SideMenuManager.default.leftMenuNavigationController?.dismissOnPush = false

    In SideMenuManager I made public
    public var activeMenu: Menu?

    In SideMenuSettings I made public from internal
    public typealias Menu = SideMenuNavigationController

    When push
    self.navigationController?.pushViewController(vc, animated: true, completion: {
    SideMenuManager.default.activeMenu?.dismiss(animated: false)
    })

  5. kaaaaai commented on Jul 27, 2023

    @kaaaaai

    It works for me version 6.5.0 Add

    extension UINavigationController { func pushViewController(_ viewController: UIViewController, animated: Bool = true, completion: (() -> Void)? = nil) { CATransaction.begin() CATransaction.setCompletionBlock(completion) viewController.view.backgroundColor = .white pushViewController(viewController, animated: animated) CATransaction.commit() } }

    Set SideMenuManager.default.leftMenuNavigationController?.dismissOnPush = false

    In SideMenuManager I made public public var activeMenu: Menu?

    In SideMenuSettings I made public from internal public typealias Menu = SideMenuNavigationController

    When push self.navigationController?.pushViewController(vc, animated: true, completion: { SideMenuManager.default.activeMenu?.dismiss(animated: false) })

    There is no push comletion method

  6. phoney commented on Oct 4, 2023

    @phoney

    @Dreamer4ik I also have this problem and did use your solution. However you can simplify it like this:

    navigationController?.pushViewController(vc, animated: true) { [weak self] in
        self?.navigationController?.dismiss(animated: true)
    }
    

    No need to directly access activeMenu (everything it relies on is public anyway).

    I see the flicker a lot less on the Simulator but I don't know what that means.

  7. phoney commented on Oct 5, 2023

    @phoney

    @Dreamer4ik I have another solution (or workaround).

    private func show(_ vc: UIViewController) {
      UIView.animate(withDuration: 0.35) {
        self.navigationController?.pushViewController(vc, animated: true)
      } completion: { finished in
        self.navigationController?.dismiss(animated: true)
      }
    }
    

    Just call show(vc) and there's no flicker. This solution works the same as yours but doesn't require the extension on UINavigationController.

    I think the Flicker is caused by two animations interfering with each other. These are most likely the animations produced by pushViewController() and dismiss(). These two workarounds of ours guarantee that the second animation doesn't start until the first one has completed.

    There's one odd thing that I notice. Here's what I see:

    I tap on the hamburger menu and the side menu opens
    I can see my VC1 on the right and the sideMenuVC
    I tap on one of the rows in the sideMenuVC
    I see the new VC2 slide in from the right
    As VC2 moves in from the right I can see the left edge of VC1 also sliding to the left behind VC2
    After VC2 fills the screen is when I see the flicker
    I really am expecting that VC1 fades away behind VC2 rather than slides to the left
    I suspect that something about what VC1 is doing during this transition is what is causing the flicker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions