开发者

Getting textfield value and set it another screen

That the user entered val开发者_运维技巧ue to a textfield I want to display another screen in the textview. So, I want to access a textfield value I used in another screen.

I don't know how to do because I'm new in ios programming. Thanks.


In AppDelegate,

Nsstring *textString;

In FirstViewController.h and SecondViewController.h

YourAppDelegate *appDelegate;

In FirstViewController.m and SecondViewController.m

in ViewDidLoad function,

appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];

You can get textField text ,

appDelegate.textString = yourTextField.text;

and in SecondViewController,

NSString* textStr = appDelegate.textString;


Set a NSString in the appDelegate for your project.

  eg. NSString* copyStr;

  //Now InYourFirstViewController.m
  appDelegate.copyStr = yourTextField.text; 

  //InSecondViewController.m
  NSString* fetchText = appDelegate.copyStr;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜