UITableViewController 闪烁行为

UITableViewController flickering behavior

我遇到了与 UITableViewController 闪烁有关的问题。

此视频中有介绍 link

我是这样展示 UITableViewController 的:

func balanceAction() {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let controller = storyboard.instantiateViewController(withIdentifier: "MainView")
        presentView(view:controller)
}

fileprivate func presentView(view: UIViewController) {

        (navigationDrawerController?.rootViewController as? ToolbarController)?.transition(to: view, duration: 0.3)
}

和库中的方法:

/**
 A method to swap rootViewController objects.
 - Parameter toViewController: The UIViewController to swap
 with the active rootViewController.
 - Parameter duration: A TimeInterval that sets the
 animation duration of the transition.
 - Parameter options: UIViewAnimationOptions thst are used
 when animating the transition from the active rootViewController
 to the toViewController.
 - Parameter animations: An animation block that is executed during
 the transition from the active rootViewController
 to the toViewController.
 - Parameter completion: A completion block that is execited after
 the transition animation from the active rootViewController
 to the toViewController has completed.
 */
open func transition(to viewController: UIViewController, duration: TimeInterval, options: UIViewAnimationOptions = [], animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) {

    rootViewController.willMove(toParentViewController: nil)
    addChildViewController(viewController)
    viewController.view.frame = rootViewController.view.bounds
    transition(from: rootViewController,
        to: viewController,
        duration: duration,
        options: options,
        animations: animations) { [weak self, viewController = viewController, completion = completion] (result) in
            guard let s = self else {
                return
            }

            viewController.didMove(toParentViewController: s)
            s.rootViewController.removeFromParentViewController()
            s.rootViewController = viewController
            s.rootViewController.view.clipsToBounds = true
            s.rootViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
            s.rootViewController.view.contentScaleFactor = Device.scale
            completion?(result)
        }
}

MainView()

class MainView: UITableViewController {

    var data = BalanceViewController()

    open override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = Color.grey.lighten5

        prepearTableView()
        prepareToolbar()
    }

    private func prepearTableView() {
        tableView.register(UINib(nibName: "BalanceCell", bundle: nil), forCellReuseIdentifier: "BalanceCell")
        self.tableView.separatorStyle = UITableViewCellSeparatorStyle.none
        self.tableView.dataSource = data
        self.tableView.delegate = self
    }

    private func prepareToolbar() {
        guard let tc = toolbarController else {
            return
        }
        tc.toolbar.title = "Balance report"
        tc.toolbar.detail = "Lifelong overall report"
    }

    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return balanceCellHeight
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
    }
}

对于任何延迟,我深表歉意,我能够重现该问题并发布了一个修复程序,它应该基于我的重现工作。请尝试Material 2.3.18

谢谢你,祝一切顺利:)