andreamazz / SlideOutNavigation

SlideOut Navigation Controller for iOS.
MIT License
210 stars 49 forks source link

Remove/Clear menu items for a section #15

Closed drallgood closed 11 years ago

drallgood commented 11 years ago

Up until your commit today, it was possible to directly manipulate the menuItems array and remove certain entries or clear them out entirely.

Do you think it would be possible to get this functionality back somehow?

I was using it to dynamically add controllers based on data I get from a server.

andreamazz commented 11 years ago

Sure thing. I'll do it tomorrow.

drallgood commented 11 years ago

Awesome. I'd do it myself, but I thought it might be something other developers need as well.

Let me know, if you need any help.

andreamazz commented 11 years ago

Ok, the menuItems property is now back in commit 382842e432cc33da216285811bd2ff9c9e042e8e I'll wait for a response on another issue before pushing the new version to cocoapods.

Cheers

drallgood commented 11 years ago

Sorry to bother you again.

Just making the menu items public again, doesn't solve the issue entirely. In order to change the items shown in the sidebar (once the view was loaded), the tableview also needs to be reloaded.

andreamazz commented 11 years ago

The tableview is automatically reloaded by the menuItems' setter:

- (void)setMenuItems:(NSArray *)menuItems
{
    // Makes sure to refresh the table data when new items are set
    _menuItems = [NSMutableArray arrayWithArray:menuItems];
    [self.tableView reloadData];
}
drallgood commented 11 years ago

Ah! Okay.

I didn't use that method, so I didn't realize it was automatically reloading the tableview.

Thanks for your awesome work!!!

drallgood commented 11 years ago

hmm.. That didn't work;

Afterwards, I get an empty table. screen shot 2013-05-02 at 2 30 00 pm

andreamazz commented 11 years ago

Weird... I'll look into it

andreamazz commented 11 years ago

Check commit 121a52c08f2b0e5d52c7ddf2661db5d3b94f683c It should be ok now.

drallgood commented 11 years ago

Yep. That's it!

Thanks for your quick fix. Really appreciate it :)

jackman0 commented 11 years ago

What I'm seeing is that the easiest way to remove and reset the menu items is to set the array to zero and re-add like the following:

        [self.slideoutController setMenuItems:[[NSMutableArray alloc]init]];

        UIViewController* controller;
        controller = [[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil];
        [self.slideoutController addViewControllerToLastSection:controller tagged:1 withTitle:cache.user.displayName andIcon:[UIImage imageWithPDFNamed:@"user.pdf" atHeight:44]];

Is that correct? Is there an easier/more efficient way? Thanks.

drallgood commented 11 years ago

That's pretty much what I'm doing right now.