GroupDetailViewController

GroupDetailViewController

本文介绍了如何将文本从文本字段发送到另一个类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 在我的应用程序Iphone中,我想做一个简单的事情,例如:我有一个带有文本字段和按钮的GroupDetailViewController。当用户按下按钮时,我想将文本从文本字段发送到另一个类ItemViewController并将此文本设置为标签。我不知道该怎么办。我是Iphone的新手,我只做了一些教程。我在这里查看:如何将文本字段值发送给另一个类但我不明白答案。谁能解释我或给我一个例子吗?In my app Iphone, I want to do a simple thing like : I have a GroupDetailViewController with a text Field and a button. When user press the button I want to send the text from textfield to another class ItemViewController and set this text to a label. I have no idea how can I do this. I am new on Iphone,I have done just some tutorials. I have looked here : How to send text field value to another class but I dont understand the answer. Can anyone explain me or give me an example?推荐答案让我们假设您的第二个类是 SecondViewController >。 现在,在SecondViewController中声明一个 NSString 并设置其属性。Let us assume that your second class is SecondViewController.Now in SecondViewController declare one NSString and set its properties. SecondViewController.hNSString *strTextValue;....@property(nonatomic,retain) NSString *strTextValue; SecondViewController.m@synthesize strTextValue;现在在 GroupDetailViewController 中,在按钮触摸事件上,将 strTextValue 中的strong> textfield 。Now in GroupDetailViewController, on button touch event, put the value from textfield in strTextValue.-(IBAction)ButtonMethod:(id)sender{SecondViewController *controller = [[SecondViewController alloc]init];controller.strTextValue = [txtField text];//Navigate to SecondViewController}放入在 SecondViewController SecondViewController.mlbl.text = strTextValue; 这篇关于如何将文本从文本字段发送到另一个类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-03 14:59