in case of two type of user login how to update menu table and functionality
in case of two type of user login how to update menu table and its functionality.
there are one situation where app have two type of user login and according to that user menu and its functionality but in this menu table created before the user selection.
how do i update menu items based on user.
I want to change the content of menu based login user.
I have the same question, i need to call func to logout from the side menu table, then update the side menu table to no longer show the LOGOUT cell ;) ..
i have tried using a protocol and delegate.. the func is never called.. don't know why..
Can you tell me which protocol and delegate I can write to change contents on side menu.
Hi, the lib doesn't handle side menu content state. you need to implement your own logic to do this. for example you can use nsnotifications.
@evnaz im kind of newbi to iOS and swift. can you pin point me on how to to this ? . i have the ensidemenu getting the content from the uitableviewviewcontroller like in the example * MyMenuTableViewcontroller , there i have an array of menuitems = ["home","contact"] . what i do is i check first in the viewWillappear via nsuserdefaults wether the user is logged via a bool , if( logged == true ) { .. it adds self.menuitems.append("logout") .. , it works if already logged in, start app .. it checks for the state of logged and adds the array, but then .. if i log out , sync nsuderdefaults and open the menu again, LOGOUT remains there.. i will like to update the array and reload the tableview before it opens.. and or // why even the viewWillAppear or viewdidload, only checks the first time for logged.. is like the view loads one time.. and stays there in memory... so.. no even viewwillappear in the uitableviewcontroller does the trick for me ..
Just to test , the first view controller inside the sidemenuwillopen() .. func sideMenuWillOpen() { print("sideMenuWillOpen") //sideMenuController()?.sideMenu?. let a = MyMenuTableViewController() a.foo() }
--- on my mymenutablecontroller --
func foo() {
self.menuitems.append("Logout YES")
tableView.reloadData()
print("foooooooooo")
print(" Count in menuitems is (self.menuitems.count) ");
for a in self.menuitems {
print(a)
}
}
in the console output i see the array adds the item, but the table doesn't reload.. :/
This is killing me, cant still figure out. Cant update the tableviewcontroller...
in the last version of the lib you can get side menu view controller instance by self.sideMenuController()?.sideMenu?.menuViewController
just call reloadData() on it whenever you need
@evnaz can u add my to Skype : LGONGALEZ
i need to show you..please 2 min. promised.
@evnaz please check https://youtu.be/nfhShPTivZ0 , after the first 20 secs.. and finish the video.. lol
i did it thnx to you @evnaz! , im calling the foo() of MyMenuTableViewController, that will first if the user is logged or not and update the table accordly
func sideMenuWillOpen() {
print("sideMenuWillOpen")
// let a = MyMenuTableViewController()
// a.foo()
let menu = self.sideMenuController()?.sideMenu?.menuViewController as! MyMenuTableViewController
menu.foo()
}
Thanks this solution also worked for me. For those who are facing same problem here is description that you have to do
Add this function to class MyMenuTableViewController and customise it according to your need and call tableView.reloadData()
func foo() { //self.menuitems.append("Logout YES") tableView.reloadData() print("foooooooooo") print(" Count in menuitems is (self.menuitems.count) "); //for a in self.menuitems { //print(a) //} }
Add this code from where you want to update menu
let menu = self.sideMenuController()?.sideMenu?.menuViewController as! MyMenuTableViewController menu.foo()
and don't forget to add ENSideMenuDelegate to class above code is being called.