I have two text fields, say name and initial in one view controller and I want to display both as one label in another view controller. How can I do this?
Asked
Active
Viewed 1,062 times
0
-
Do you wants to display value of both textfield in Label?? – Mohit Nov 01 '14 at 05:17
-
1Better to go through some tutorials for sending data from one page to another page it's quite easy but you are beginner so you need to learn some basic knowledge. – Balu Nov 01 '14 at 05:19
-
Your question has been answered here http://stackoverflow.com/a/9736559/898274 – Kalenda Nov 01 '14 at 05:28
2 Answers
1
To send data from one page to another have a look SO answer here And to Adding/Concatenating two string you have two ways -
- Use NSMutableString that has appendString method.
- Save nsstring in NSArray and use componentsJoinedByString Method
0
assume that this is your first Viewcontroller
this is your UIButton
action for Navigating secondVIewcontroller
- (IBAction)btnSignUp_touchUpInside:(id)sender
{
SignUpViewController *vc=[[SignUpViewController alloc]init]; //addyour secondviewcontroller
vc.strFromUnlinkPage=[NSString stringWithFormat:@"%@. %@",yourinitialtextfield.text,yournametextfirld.text]; // here we concatennating 2 strings
[self.navigationController pushViewController:vc animated:YES];
}
this is your secondVIewcontroller.h
create the one NSString
just like
@interface SignUpViewController : BaseViewController<UITextFieldDelegate, UIAlertViewDelegate>{
}
@property (retain, nonatomic) NSString *strFromUnlinkPage;
@property (retain, nonatomic) IBOutlet UILabel *lblGuide; //assumethat this is your secondviewcontroller `UIlabel` Name
in your .m ViewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
self.lblGuide.text=[NSString stringWithFormat:@"%@", strFromUnlinkPage];
}

Anbu.Karthik
- 82,064
- 23
- 174
- 143