iSofTom / STCollapseTableView

A UITableView subclass that automatically collapse and/or expand your sections
MIT License
137 stars 62 forks source link

Dismiss view controller have STClollapseTableView causes error #15

Open phongnguyensg opened 8 years ago

phongnguyensg commented 8 years ago

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

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:

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 commented 8 years ago

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 commented 8 years ago

Thanks. I have the problem yesterday. @phongnguyensg

bndouglas commented 8 years ago

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 commented 7 years ago

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