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

Backbutton while SCLAlertView is shown causes zombie views #25

Closed
deanq opened this issue Nov 6, 2014 · 8 comments
Closed

Backbutton while SCLAlertView is shown causes zombie views #25

deanq opened this issue Nov 6, 2014 · 8 comments

Comments

@deanq
Copy link

deanq commented Nov 6, 2014

When you have an alert shown, and the back button is clicked to take the User back to the parent view, the entire view controller stays in memory and never goes away. The way you can test this in simulator is to print a line in your deinit or didReceiveMemoryWarning for the child view. You'll notice that child views that pop back to root without an alert shown will deinit, and a line will not print when you didReceiveMemoryWarning. In contrast, if you have a child view with an alert shown and hit back, you will not see the deinit line and didReceiveMemoryWarning will print a line for that child view.

    deinit {
        NSLog("deinit \(self)")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        NSLog("didReceiveMemoryWarning \(self)")
    }

@deanq
Copy link
Author

deanq commented Nov 7, 2014

I have a work-around for this, and I'd like to share it in case someone else out there is seeing this problem:

class MyViewController: UIViewController {
    // retainer
    var alertView: SCLAlertView!

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

        if alertView != nil && alertView.isViewLoaded() {
            // zombie killer
            alertView.hideView()
            alertView = nil
        }
    }

    // factory-ish
    func getDialog() -> SCLAlertView {
        alertView = SCLAlertView()
        // my uniformed customization below
        alertView.backgroundType = .Blur
        alertView.hideAnimationType = .FadeOut
        alertView.showAnimationType = .FadeIn

        return alertView
    }

    func doingSomethingHere() {
        let dialog = getDialog()

        dialog.addButton("Yes", target: self, selector:"fooBar")
        dialog.addButton("No", target: self, selector: "notfooBar")

        dialog.showInfo(self,
            title: "My Title",
            subTitle: "lorem ipsum",
            closeButtonTitle: "Cancel",
            duration: 0)
    }

}

... let ARC work for you.

@dogo
Copy link
Owner

dogo commented Nov 7, 2014

@deanq
I have to ask, why you are programming in swift? I think you are using the wrong version, this is the Objective-C version

the Swift version is this one
/~https://github.com/vikmeup/SCLAlertView-Swift

@deanq
Copy link
Author

deanq commented Nov 7, 2014

Oh, it works fine on Swift using bridging header file. I’m using Cocoa Pod for my project. Tthe Swift version of this library doesn’t compile yet (it’s a cocoa pod problem). Until that is fixed, I’ll continue to use the objective-c version with a bridging header file.

On Nov 6, 2014, at 4:55 PM, Diogo Autilio notifications@github.com wrote:

@deanq
I have to ask, why are you programming in swift? I think you are using the wrong version of the library, this is the Objective-C version

the Swift version is this one
/~https://github.com/vikmeup/SCLAlertView-Swift


Reply to this email directly or view it on GitHub.

@dogo
Copy link
Owner

dogo commented Nov 7, 2014

Duh! I'm so dumb! hahaha, I'll take a look later on this issue

@dogo
Copy link
Owner

dogo commented Nov 28, 2014

@deanq
Seems fine here (Tested with a UINavigationController Sample)

Tested with :
iPhone 6 Simulator

iOS 8.1.1
iPhone 5s Real world device :P

Please take a look
https://dl.dropboxusercontent.com/u/12595498/dealloc.mov

@deanq
Copy link
Author

deanq commented Nov 29, 2014

I guess it only happens in Swift. Deinit does not get called at all unless I kill the reference. I have updated to the :head build, and it's still a zombie for me.

@dogo
Copy link
Owner

dogo commented Dec 1, 2014

@deanq May I close this issue? since it is a swift error

@deanq
Copy link
Author

deanq commented Dec 1, 2014

Sure. Go ahead.

@dogo dogo closed this as completed Dec 1, 2014
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