I am not able to get text field value in to next tab viewController. I am using TabBarController with two tabs

时间秒杀一切 提交于 2019-12-11 16:13:25

问题


I have a TabBarController with two tabs; first is InputViewController and second one is TableviewController.

Input view controller has two text fields when I enter the text, after that I want to receive that text filed value in to TableviewController (in the next tab). It does not receive the value.


回答1:


Try to use this concept..... Declare two variables in Second tab that is Tableviewcotroller.. For exa..

NSString *strname;
NSString *straddr;

@property and @synthesize both...

Now, in your *InputViewCotroller*tab, create and initialize object of TableViewcotroller, using this object, access these varibles. Like, you want to get values of textfields.

Tableviewcotroller *objTable = ........
objTable.strname = self.textName.text;
objTable.straddr = self.txtAddr.text;

Implement this concept in your project...Hope this helps you...:)




回答2:


What ever value you have in input view controller like

  NSString*text1=textbox1.text;
  NSString*text2=textbox2.tex;

In the method where you are moving to next view you should pass the value to the table view controller like this

DetailViewController*tblViewController=[[DetailViewController alloc]init];
NSString*textValue1=text1;

tblViewController.textValue1=textValue;

[self.navigationController pushViewController:tblViewController];

you should alos have textValue NSString in tableView controller also to assign value



来源:https://stackoverflow.com/questions/9901764/i-am-not-able-to-get-text-field-value-in-to-next-tab-viewcontroller-i-am-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!