ios - To fetch data from one page to another -
i know question has been answered before, have difficulty among those. there textfield on 1 page , want retrieve it's content label located on next page clicking on button.
i have tried this. tfname id of textfield in page 1.
-(ibaction)onclick:(id)sender { nsstring *string1 =tfname.text; }
and in page2
- (void)viewdidload { [super viewdidload]; label1.text=string1; }
here simple example code:
class a.h :
uitextfield *tfname;
class a.m :
tfname.text = @"hello world"; -(ibaction)onclick:(id)sender { classb *b = [[classb alloc]initwithnibname@"classb"]; b.string1 =tfname.text; [self.navigationcontroller pushviewcontroller:b animated:yes]; }
class b.h :
@property(..)nsstring *string1;
class b.m :
label1.text = _string1.
note: need import classb in classa, i.e., #import "classb.h"
hope helps.
Comments
Post a Comment