如何将文本字段值发送到另一个类 [英] How to send text field value to another class

查看:47
本文介绍了如何将文本字段值发送到另一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有文本字段和按钮的UIViewController.当用户单击按钮时,我想移动到TableViewCotroller并将文本字段的值发送到表视图.我用这个代码:

i have a UIViewController with a text Field and a button . When the user click the button , i want to move to a TableViewCotroller and send the value of the text field to the table view . I use this code :

StatusTableViewController *statuttableview =[[StatusTableViewController alloc]initWithNibName:@"StatusTableViewController" bundle:nil];
    [self.navigationController pushViewController:statuttableview animated:YES];

它可以工作,但是我不知道如何从StatusTableViewController访问文本字段值.请帮助

It work but i dont know how i will access to the text field value from StatusTableViewController . Help please

推荐答案

您绝对应该更深入地了解基础知识....您必须在 StatusTableViewController 中添加 NSString 属性,并在自定义init或初始化后使用其setter对其进行设置.

You should definitely go a little deeper into the basics.... You have to add a NSString property to the StatusTableViewController and set it in a custom init or with its setter after initialization.

做类似

NSString *myText;

...

@property(nonatomic, retain) NSString *myText;

....

和/或

-(id)initWithNibName:(NSString *)nibname bundle:(NSBundle *)bundle text:(NSString *)text;

在StatusTableViewController.m中完成

in StatusTableViewController.m do

@synthsize myText;

和/或

-(id)initWithNibName:(NSString *)nibname bundle:(NSBundle *)bundle text:(NSString *)text
{
   if(self = [super initWithNibName:nibname bundle:bundle])
   {
     self.myText = text;
   }
} 

,然后在您的代码中调用自定义init或

and in you code call the custom init or

statuttableview.myText =文本

statuttableview.myText = text

.

这篇关于如何将文本字段值发送到另一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆