我有两个文本字段,比如一个视图控制器中的name和initial,我想在另一个视图控制器中同时显示两个标签。我怎么能这样做?
答案 0 :(得分:1)
要将数据从一个页面发送到另一个页面,请查看SO answer here并添加/连接两个字符串,您有两种方式 -
答案 1 :(得分:0)
假设这是您的first Viewcontroller
这是导航UIButton
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];
}
这是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
.m ViewDidLoad
中的
- (void)viewDidLoad
{
[super viewDidLoad];
self.lblGuide.text=[NSString stringWithFormat:@"%@", strFromUnlinkPage];
}