将字符串值从一个视图控制器传递到另一个视图控制器

问题描述:

我正在使用这种方式将字符串值从一个视图控制器传递到另一个视图控制器,但它仍然不起作用。请帮忙!从主菜单登录方法我的web服务的结果值传递给SecondMenu:将字符串值从一个视图控制器传递到另一个视图控制器

- (IBAction)MainMenuLogin_Method:(id)sender 
{ 
    SecondMenu *lc2=[[SecondMenu alloc] initWithNibName:@"SecondMenu" bundle:nil]; 

    [email protected]"hello";// in actual it is a soap result 

    //[self presentModalViewController:lc2 animated:YES]; 
    [[[[UIApplication sharedApplication] delegate] window] addSubview:lc2.view]; 
} 
+0

定义“不工作”。你没有看到什么行为? – TechZen

+0

textfield为空,它不显示字符串hello。 – shreedevi

最可能的解释是,username_TextField资源尚未与实际的UITextView。 (1)检查SecondMenu标头中username_TextField的属性定义是否定义为IBOutlet,并且(2)它是否实际上在Interface Builder中进行了链接。

编辑:

看着你的链接的全部代码,它看起来像username_TextField属性是类LoginController的财产,但在此代码,你有实例lcv2SecondMenu类。您提供的代码中没有任何内容显示SecondMenu类具有username_TextField属性。如果初始化lcv2作为LoginController的一个实例,上面的代码将工作,假设您已经在接口构建器中修正了插座。

+0

我已粘贴完整的代码,请检查此链接。 http://stackoverflow.com/questions/1693783/how-to-pass-a-string-value-from-one-controller-to-another。 – shreedevi

+0

你还没有粘贴整个代码,因为在这两篇文章中都没有'SecondMenu'的类定义。如果SecondMenu缺少'username_TextField'属性,或者它没有连接到nib中,则文本字段将不会填充。 – TechZen