objective c - Send Data to View Controller of choice -
i trying perform know simple, yet not sure of syntax.
first, user input facebook login info, signs them in. code pulls profile picture, username, email, , facebook button , displays in "loginiewcontroller". prof pic view controller called profilepicture, username called lblusername, email lblemail, , fb button called loginbutton.
all want write code sends these 4 values profileviewcontroller, not next view controller segue, displays profile picture, username, email , * logout * button. below code loginviewcontroller:
***fyi, code shows initial view of fb login button, regular login button, , sign button, profile picture view, username, , email hidden start. once logged in, have same view controller show profile picture, username, , email, hiding ever login button *not *clicked.
#import "loginviewcontroller.h" @interface loginviewcontroller () @end @implementation loginviewcontroller - (void)viewdidload { [super viewdidload]; nologin.layer.cornerradius = 3; [nologin.layer setshadowcolor:[uicolor blackcolor].cgcolor]; [nologin.layer setshadowopacity:0.1]; [nologin.layer setshadowradius:0.2]; [nologin.layer setshadowoffset:cgsizemake(0.0, 1.1)]; [nologin.layer setbordercolor:[uicolor blackcolor].cgcolor]; [nologin.layer setborderwidth:0.1f]; self.loginbutton.delegate = self; [self togglehiddenstate:yes]; _signup.hidden = no; nologin.hidden = no; self.lblloginstatus.text = @""; self.loginbutton.readpermissions = @[@"public_profile", @"email", @"user_friends"]; // self. } -(void)loginviewshowingloggedinuser:(fbloginview *)loginview{ self.lblloginstatus.text = @""; [self togglehiddenstate:no]; [self toggleunhiddenstate:yes]; uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil]; uitabbarcontroller *tabcontroller = (uitabbarcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"tabcontroller"]; [self presentmodalviewcontroller:tabcontroller animated:yes]; } -(void)loginviewfetcheduserinfo:(fbloginview *)loginview user:(id<fbgraphuser>)user{ nslog(@"%@", user); self.profilepicture.profileid = user.objectid; self.lblusername.text = user.name; self.lblemail.text = [user objectforkey:@"email"]; } -(void)loginviewshowingloggedoutuser:(fbloginview *)loginview{ self.lblloginstatus.text = @""; [self togglehiddenstate:yes]; _signup.hidden = no; nologin.hidden = no; } -(void)loginview:(fbloginview *)loginview handleerror:(nserror *)error{ nslog(@"%@", [error localizeddescription]); } -(void)togglehiddenstate:(bool)shouldhide{ self.lblusername.hidden = shouldhide; self.lblemail.hidden = shouldhide; self.profilepicture.hidden = shouldhide; self.begin.hidden = shouldhide; self.loggedinwallpaper.hidden = shouldhide; } -(void)toggleunhiddenstate:(bool)shouldshow{ _signup.hidden = yes; nologin.hidden = yes; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } - (ibaction)unwindtologin:(uistoryboardsegue *)segue { } #pragma mark - navigation // in storyboard-based application, want little preparation before navigation /*- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { [segue destinationtabbabcontroller] // new view controller using [segue destinationviewcontroller]. // pass selected object new view controller. } - (ibaction)j:(id)sender { }*/ - (ibaction)enter:(id)sender forevent:(uievent *)event { } @end
after have initialised viewcontroller want present, can access its' properties (those you've mentioned , assign them values want).
-(void)loginviewshowingloggedinuser:(fbloginview *)loginview{ self.lblloginstatus.text = @""; [self togglehiddenstate:no]; [self toggleunhiddenstate:yes]; uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil]; uitabbarcontroller *tabcontroller = (uitabbarcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"tabcontroller"]; //get first controller displayed (could of different index, depends on how set up) uiviewcontroller *firstcontroller = [[((uitabbarcontroller *)self.window.rootviewcontroller) viewcontrollers] objectatindex:0];//modify uiviewcontroller view controller class name... //now set properties of controller info need. i've added one, please continue others... firstcontroller.lblusername = self.lblusername; //finally, present tabcontroller. [self presentmodalviewcontroller:tabcontroller animated:yes]; }
Comments
Post a Comment