2014-11-01 63 views
0

我有兩個文本字段,比如一個視圖控制器中的名稱和初始值,並且我想在另一個視圖控制器中同時顯示一個標籤。我怎樣才能做到這一點?將兩個文本字段添加到iOS中的一個標籤中

+0

你想要顯示的標籤文本框都值? – Mohit 2014-11-01 05:17:28

+1

更好地通過一些教程發送數據從一個頁面到另一個頁面很容易,但你是初學者,所以你需要學習一些基本知識。 – Balu 2014-11-01 05:19:36

+0

您的問題已在此解答http://stackoverflow.com/a/9736559/898274 – Kalenda 2014-11-01 05:28:00

回答

0

以爲這是您的first Viewcontroller

這是你的瀏覽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]; 

} 

UIButton行動,這是你的secondVIewcontroller.h創建一個NSString就像

@interface SignUpViewController : BaseViewController<UITextFieldDelegate, UIAlertViewDelegate>{ 

} 
@property (retain, nonatomic) NSString *strFromUnlinkPage; 

@property (retain, nonatomic) IBOutlet UILabel *lblGuide; //assumethat this is your secondviewcontroller `UIlabel` Name 

.MViewDidLoad

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
self.lblGuide.text=[NSString stringWithFormat:@"%@", strFromUnlinkPage]; 
} 
1

從一個頁面發送數據到另一個看看SO answer here而要添加/連接兩個字符串,有兩種方式 -

  1. 使用的NSMutableString有appendString方法。
  2. 保存的NSString在NSArray中,並使用componentsJoinedByString方法
相關問題