ios - How to show last view controller with data in it after password form? -
i have 2 storyboards. first used showing password. has 2 view controllers , own navigation controller. second storyboard contains view controllers app , navigation controller. user should type in password every time launches app if wouldn't disable in settings.
here appdelegate.m :
- (void)startapp { // override point customization after application launch. if ([security getuseornotpassword] || (no == [settings isnotfirstapprun]) ) [self showloginscreen]; else [self showmainvc]; } -(void)showloginscreen { if (no == [settings isnotfirstapprun]) [settings setdefaultlanguage]; uistoryboard *storyboard = [uistoryboard storyboardwithname:@"password" bundle:nil]; passwordvc *passwordview = [storyboard instantiateviewcontrollerwithidentifier:@"login"]; if (no == [settings isnotfirstapprun] ) { passwordview = [passwordview initforaction:passcodeactionset]; [security saveuseornotpassword:yes]; } else { passwordview = [passwordview initforaction:passcodeactionenter]; passwordview.passcode = [security getpassword]; //pass password verify } passwordview.delegate = self; uinavigationcontroller *navigationcontroller= [[uinavigationcontroller alloc] initwithrootviewcontroller:passwordview]; [[(appdelegate*)[[uiapplication sharedapplication] delegate] window] setrootviewcontroller:navigationcontroller]; [self.window makekeyandvisible]; } -(void)showmainvc { uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil]; maintablevc *mainvc = [storyboard instantiateviewcontrollerwithidentifier:@"main"]; leftmenuvc *menuvc = [storyboard instantiateviewcontrollerwithidentifier:@"leftmenu"]; revealvc *mainrevealcontroller = [[revealvc alloc] initwithrearviewcontroller:menuvc frontviewcontroller:mainvc]; uinavigationcontroller *navigationcontroller= [[uinavigationcontroller alloc] initwithrootviewcontroller:mainrevealcontroller]; [[(appdelegate*)[[uiapplication sharedapplication] delegate] window] setrootviewcontroller:navigationcontroller]; }
here delegate method password: if user type in "correct" password main screen opening:
- (void)passwordvcdidenterpasscode:(passwordvc *)controller { [self.window.rootviewcontroller dismissviewcontrolleranimated:yes completion:nil]; [self performselector:@selector(showmainvc) withobject:nil afterdelay:0.1]; }
and finally: displaying password every time when application become active
- (void)applicationdidbecomeactive:(uiapplication *)application { // restart tasks paused (or not yet started) while application inactive. if application in background, optionally refresh user interface. [self startapp]; }
my question is: in schema displaying password form how show user's last view controller in typed , data in (text in textfields , etc)? because if user pressed home button , after launched app data disappeared , there main screen of app=) maybe should change algorithm showing password form? thanks answering , advising! have nice coding!)
the password form has nothing this, once application killed (which @ point, if in background) data in memory lost.
first of have figure out way store (persist) application's state. can maybe nsuserdefaults
basic persistence, such as: user's last visited screen, last visited time, or similar.
but more advanced persistence stores data user has entered have code own data model. there many ways this, can give starting pointers:
- if have relational structured data, use core data.
- for basic storage can use property lists , files.
- for synchronisation can use dropbox or icloud api's.
first need decide need , how going approach problem. need write little bit of code working properly.
Comments
Post a Comment