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

Dismiss view controller have STClollapseTableView causes error #15

Open
phongnguyensg opened this issue Oct 9, 2015 · 4 comments
Open

Comments

@phongnguyensg
Copy link

I'm embedded STCollapseTableView to a view controller to send it as modal to super view controller. But some thing wrong happens at: STCollapseTableView.h from line 95

  • (void)setDelegate:(id)newDelegate
    {
    if (newDelegate != self.collapseDelegate)
    {
    self.collapseDelegate = newDelegate;
    [super setDelegate:self.collapseDelegate?self:nil];
    }
    }

When the modal view controller was dismissed. A new delegate send to this function as param and it's nil. The error cause at line 97 when trying to compare. I fix it like this:

  • (void)setDelegate:(id)newDelegate
    {
    if(!newDelegate){
    return;
    }
    if (newDelegate != self.collapseDelegate)
    {
    self.collapseDelegate = newDelegate;
    [super setDelegate:self.collapseDelegate?self:nil];
    }
    }

Check whether new delegate is nil and vice versa. Unless it's nil, move to next expression! You guys should check and fix it. It work well on independent view controller but issue only happened when embedded to a view controller and show it as modal.

@lgamble
Copy link

lgamble commented Nov 17, 2015

I had the same when using UINavigationController and pushing it as a view. This fix works, but any ideas how would I go about changing this if I'm using CocoaPods, because as soon as I do a pod update, it will remove any changes I've made.

@ryan715
Copy link

ryan715 commented Jul 1, 2016

Thanks. I have the problem yesterday. @phongnguyensg

@bndouglas
Copy link

bndouglas commented Aug 28, 2016

I have the same problem with my app crashing due to a runtime error in STCollapseTableView.m.
The error occurs when navigating away from a an STCollapseTable, although I'm using an STCollapseTableView within a Navigation controller rather than presenting it modally as above.
The same error occurs in my app if I'm using the back button, or using a burger menu to navigate to a different screen.

This is my fix (pretty much the same as above):

- (void)setDelegate:(id<UITableViewDelegate>)newDelegate
{
    if (newDelegate != NULL){      //add check
        if (newDelegate != self.collapseDelegate)
        {
            self.collapseDelegate = newDelegate;
            [super setDelegate:self.collapseDelegate?self:nil];
        }
    }  //don't forget to close the if
}

I really hate editing code in a CocoaPod in case an update removes my fix. I'd appreciate if this fix could be incorporated into a the next release. Thanks.

@kb100824
Copy link

This is my modified:
self.collapseDelegate = newDelegate;
[super setDelegate:self.collapseDelegate?self:nil];

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

5 participants