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

UIView that conforms StatefulViewController protocol cannot be destroyed #71

Open
YK-Unit opened this issue Apr 17, 2019 · 2 comments
Open

Comments

@YK-Unit
Copy link

YK-Unit commented Apr 17, 2019

UIView that conforms StatefulViewController protocol does not be destroyed.

Here is a StatefulViewControllerDemo.zip to illustrate this issue.

PS: the core code

class StateView: UIView, StatefulViewController {

    public var defaultLoadingView: UIView? {
        let defaultView = UIView()
        defaultView.backgroundColor = UIColor.white

        let label = UILabel()
        label.textColor = UIColor.blue
        label.text = "loading..."
        defaultView.addSubview(label)
        label.snp.makeConstraints { (maker) in
            maker.height.equalTo(20)
            maker.centerX.equalToSuperview()
            maker.top.equalToSuperview().offset(160)
        }
        return defaultView
    }

    public var defaultEmptyView: UIView? {
        let defaultView = UIView()
        defaultView.backgroundColor = UIColor.white

        let label = UILabel()
        label.textColor = UIColor.blue
        label.text = "no content"
        defaultView.addSubview(label)
        label.snp.makeConstraints { (maker) in
            maker.height.equalTo(20)
            maker.centerX.equalToSuperview()
            maker.top.equalToSuperview().offset(160)
        }
        return defaultView
    }


    override init(frame: CGRect) {
        super.init(frame: frame)

        loadingView = defaultLoadingView
        emptyView = defaultEmptyView
        setupInitialViewState()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    // FIXME: StateView cannot be destroyed
    deinit {
        print("StateView deinit ...")
    }

    func hasContent() -> Bool {
        return false
    }

}
@tungdx
Copy link

tungdx commented May 14, 2019

Same issue, have you managed to solve it? @YK-Unit

@YK-Unit
Copy link
Author

YK-Unit commented May 18, 2019

Same issue, have you managed to solve it? @YK-Unit

Yes, I just solve it now. And I have crated a PR #73. What's more, you can use the StatefulViewControllerDemo_v2.0.0.zip to verify it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants