简体   繁体   中英

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:

- (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. (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.

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 . There is nothing in the code you provided to show that the SecondMenu Class has a username_TextField property. If you initialize lcv2 as an instance of LoginController the code above will work assuming you have the outlets wired correcting in interface builder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM