Update menuItem title after url request
Hi, thanks for this awesome library.
In my app I need to refresh the title of some menu, calling a url request (with Alamofire library). After I got the string title from the request, how can I update the menuItem title?
I'm trying to add the feature, but it's taking so much time...
Well, calling setup method with new option is the only way for now.
Thank you @kitasuke,
it works, but every time I call setup the current menuItem comes back to the first one.
So for example if I am in the fourth view controller and I call setup, the view controller and the menu reset to the first one.
Any way to avoid this?
UPDATE:
I also tried to call setupMenuView (after making it public) so the view controller doesn't reset anymore, but the menu still reset to the first one.
Hi @KimPark89 ,
I found myself with the same issue and I "kinda" found a nice workaround.
The solution I found is to call setup(options: PagingMenuControllerCustomizable) with a few other lines (explanation below):
let currentPage = self.pagingController!.currentPage
let options = PagingMenuHelper.options()
self.pagingController!.setup(options as PagingMenuControllerCustomizable)
self.pagingController!.move(toPage: currentPage, animated: false)
In this example self.pagingController is the instance of the PagingMenuController. I first save the current menu item position I'm on, then I update the options with my new values and lastly I restore the old position.
This works fine with the only problem being the thin bar under the menu items that does display animation even if I set animated: false.
For some context on why I needed this (hopefully I'm giving @kitasuke some motivation), I am Localizing text in my app and I could not figure out any better way to update these labels when the language change triggers (I have implemented a language change in real time).
Hopefully this was useful, Cheers!
Thank you @pinoy4, it works!