Passing variables to different view controllers

后端 未结 5 680
有刺的猬
有刺的猬 2021-01-14 22:01

I\'ve searched and searched but nothing has really worked.

I\'m trying to set a textvalue from a text box, into a string or whatever, so that I can call it up later

5条回答
  •  囚心锁ツ
    2021-01-14 22:53

    You could make an instance variable on the other view controller retain or copy the value before you push/pop the view. For example:

    OpenNextViewController *varNextPageController = [[OpenNextViewController alloc] initWithNibName:@"OpenNextViewController" bundle:nil];
    varNextPageController .textString= self.textString;
    [[self navigationController] pushViewController:varNextPageController animated:YES];
    [varNextPageController release];
    

    In "OpenNextViewController" in this example have an instance variable "textString" that retains or copies (depending on your needs) your text.

提交回复
热议问题