How to make one page pass on a message to another?

寵の児 提交于 2020-01-06 20:07:46

问题


My problem is different users will have access to different products. Say User 1 has access to 3 whereas User 2 has access to all 4.

Can I have something upon Login where if User 1 logs in, it will tell the MainView to only show 3 cells? Something like ViewDidLoad in the MainView to read what the Login Page echo-ed?

Can that be done?

Thanks.


回答1:


Store a global variable in appdelegate like numberOfCells. Assign value to it by the condition of your login.

Once your MainView is about to display like in viewWillAppear, get the value of numberOfCells from appdelegate and chage your UI.

You can get the appdelegate reference as follows.

SampleAppDelegate *appdelegate=(SampleAppDelegate*)[[UIApplication sharedApplication] delegate];



回答2:


If you keep track of the user who has 'logged-it' you can configure your views based on that user/profile.




回答3:


why don't you use NSUserDefaults??

You can save alot of field in it and will be accessible throughout your project.



来源:https://stackoverflow.com/questions/6109543/how-to-make-one-page-pass-on-a-message-to-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!