SWRevealViewController icon indicating copy to clipboard operation
SWRevealViewController copied to clipboard

Update Menu item

Open vicky1000266 opened this issue 6 years ago • 5 comments

Hi, sorry for bothering, but is adding/deleting a menu item when I click on a button possible? I'm trying to update menu item dynamically, but I haven't succeeded yet. For testing purposes, I've added another button which opens menuVC (the menu on the right in first picture) when you click it, and it works fine when I click said button (meaning that the menuItemArray in menuVC has been updated after clicking the button). But why doesn't the actual side menu get updated? 8236763400756 (left one is the actual menu, right one is use for testing if menuItemArray has changed)

2018-07-09 14 27 19 (this is my code, Key: "hasChangedReward" will tell if it's needed to update menuItemArray)

vicky1000266 avatar Jul 09 '18 06:07 vicky1000266

viewDidLoad is only called once. You have to update your data source (your arrays) in viewWillAppear and reload the table view.

iDevelopper avatar Jul 09 '18 06:07 iDevelopper

Thanks for answering! I've searched some information about reload table view in viewWillAppear override function, and I found that I can't call reload function in viewWillAppear, but I can call it at another tableview function, I'm wondering that what's the problem I'm having now. Thanks again.

vicky1000266 avatar Jul 09 '18 16:07 vicky1000266

Your controller is not a UITableViewController but a UIViewController, so you have to have an outlet for your table view connected with the storyboard. After that you will be able to use it anywhere in the code.

iDevelopper avatar Jul 09 '18 21:07 iDevelopper

Thanks a lot, I've solved the problem by taking your advice:))

vicky1000266 avatar Jul 10 '18 02:07 vicky1000266

viewDidLoad is only called once. You have to update your data source (your arrays) in viewWillAppear and reload the table view.

Thanks Brother i've solved the same problem by implementing your upper advice. :-)

Ali-Aqdas avatar Apr 04 '19 15:04 Ali-Aqdas