[英]Pass a string value from one view controller to another
I am using this way to pass a string value from one view controller to another but still it's not working. 我正在使用这种方式将字符串值从一个视图控制器传递到另一个视图控制器,但仍然无法正常工作。 Please help!
请帮忙! From the main menu login method I pass a result value of a web service to SecondMenu:
从主菜单登录方法中,我将Web服务的结果值传递给SecondMenu:
- (IBAction)MainMenuLogin_Method:(id)sender
{
SecondMenu *lc2=[[SecondMenu alloc] initWithNibName:@"SecondMenu" bundle:nil];
lc2.username_TextField.text=@"hello";// in actual it is a soap result
//[self presentModalViewController:lc2 animated:YES];
[[[[UIApplication sharedApplication] delegate] window] addSubview:lc2.view];
}
The most likely explanation is that the username_TextField
property is not linked to the actual UITextView. 最可能的解释是,
username_TextField
属性未链接到实际的UITextView。 (1) Check that the property definition of username_TextField
in the SecondMenu
header is defined as an IBOutlet and that (2) it is actually linked up in Interface Builder. (1)检查
SecondMenu
标头中username_TextField
的属性定义是否定义为IBOutlet,以及(2)实际上已在Interface Builder中将其链接起来。
Edit: 编辑:
Looking at the full code at your link, it looks like the username_TextField
property is a property of the Class LoginController
but in this code you have instance lcv2
as Class SecondMenu
. 查看链接中的完整代码,看来
username_TextField
属性是Class LoginController
的属性,但是在此代码中,您具有实例lcv2
作为Class SecondMenu
。 There is nothing in the code you provided to show that the SecondMenu
Class has a username_TextField
property. 您提供的代码中没有任何内容表明
SecondMenu
类具有username_TextField
属性。 If you initialize lcv2
as an instance of LoginController
the code above will work assuming you have the outlets wired correcting in interface builder. 如果您将
lcv2
初始化为LoginController
的实例,则上面的代码将在您假设接口构建器中的插座已接线校正的情况下起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.