i have 1 tabbarcontroller have login , complete tab. want click on logout button in logintab, data , tableview in complete tab reset. used code not work:
in completetab.m:
-(void) viewdidload { temp = [[nsmutablearray alloc] init]; iduploadarray= [[nsmutablearray alloc] init]; filecompletedarray = [[nsmutablearray alloc] init]; diffarr= [[nsmutablearray alloc] init]; _tableview = [[uitableview alloc] initwithframe:self.view.bounds]; tabledata = [[nsarray alloc] initwithobjects:filecompletedarray,nil]; // [_tableview setallowsselection:yes]; //tableview.datasource = self; // [self.view addsubview:tableview]; // [self parsexmlfile:@"x"]; nsurl *url1 = [nsurl urlwithstring:@"server.com"]; afhttpclient *httpclient = [[afhttpclient alloc] initwithbaseurl: url1] ; .... temp = [filecompletedarray mutablecopy]; _tableview.datasource = self; _tableview.delegate=self; [self.view addsubview:_tableview]; } failure:^(afhttprequestoperation *operation, nserror *error) { nslog(@"error: %@", error);//: %@", operation.responsestring); } ]; [httpclient enqueuehttprequestoperation:operation]; } -(void) resetall { [temp removeallobjects]; [filecompletedarray removeallobjects]; [diffarr removeallobjects]; [_tableview reloaddata]; }
in logintab.m:
- (ibaction)logoutbutton:(id)sender { login = false; username.hidden = no; pass.hidden = no; loginbutton.hidden = no; logoutbutton.hidden = yes; //make arrays reset username.text =@""; pass.text = @""; [completeview resetall]; }
i debug: when click on logout button,it called resetall() function each variable 0x000000. cannot reset data , reload tableview. can me? thanks
since logout button in logintab, doesnot have reference completetab. need keep completetab reference in app. best choice in appdelegate. on logout button click, take instance , reset data.
keep completab view controller instance in appdelegate this
@property (nonatomic, retain) uiviewcontroller *completetab; self.completetab = \\your complete tab viewcontroller instance.
then on logout button click
[(appdelegate *)[[uiapplication sharedapplication] delegate].complettab resetall]
hope helps.
Comments
Post a Comment