Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
northcity opened this issue Jul 7, 2022 · 7 comments

Comments

@northcity
Copy link

northcity commented Jul 7, 2022

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重新运行后也可以复现,但当我推了几次页面后,这个问题就自己消失了。

@northcity
Copy link
Author

northcity commented Jul 7, 2022

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

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

@viihua
Copy link

viihua commented Dec 20, 2022

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

@Kedar-27
Copy link

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

@Dreamer4ik
Copy link

Dreamer4ik commented Apr 25, 2023

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)
})

@kaaaaai
Copy link

kaaaaai commented Jul 27, 2023

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

@phoney
Copy link

phoney commented Oct 4, 2023

@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.

@phoney
Copy link

phoney commented Oct 5, 2023

@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
Projects
None yet
Development

No branches or pull requests

6 participants