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

Update Menu item #795

Open
vicky1000266 opened this issue Jul 9, 2018 · 5 comments
Open

Update Menu item #795

vicky1000266 opened this issue Jul 9, 2018 · 5 comments

Comments

@vicky1000266
Copy link

vicky1000266 commented Jul 9, 2018

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)

@iDevelopper
Copy link

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

@vicky1000266
Copy link
Author

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.

@iDevelopper
Copy link

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.

@vicky1000266
Copy link
Author

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

@Ali-Aqdas
Copy link

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. :-)

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

3 participants