如何从表格视图的自定义单元格内的 TextField 获取值(标签)以发布到 te URL [英] How to Get the value(label) from the TextField inside the custom cell of a table View to post on te URL

查看:11
本文介绍了如何从表格视图的自定义单元格内的 TextField 获取值(标签)以发布到 te URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的 iOS 应用程序将用户键入的文本传递给 URL.相关代码贴在下面.当我运行应用程序时,文本没有被分配任何值.它保持为空.

I want my iOS app to pass to a URL the text the user types. The relevant code is pasted below. WHen I run the app, the text does not get assigned any value. It stays as null.

我是 iOS 编程新手,可能在这里遗漏了一些明显的东西.任何帮助/指针将不胜感激.

I am new to iOS programming and am probably missing something obvious here. Any help/pointers will be appreciated.

Mac 操作系统版本:10.6.8(64 位)Xcode 版本:3.2.3

Mac OS version : 10.6.8 (64 bit) Xcode version : 3.2.3

在 snapshop 中..我创建了一个表格视图并将自定义单元格放置在表格的每一行内.TextField 位于自定义单元格视图内.Post 是 textField 旁边的一个按钮,它是一个完成按钮.如果我单击该按钮,我们在 textField 中输入的文本应发布在我在代码片段中指定的 URL 上."

In the snapshop.. "I have created a Table View and placed custom cell inside each row of a table. TextField is inside the custom cell view. Post is a button next to the textField which is a done Button. If I click that button, the text we are entering in the textField should post on URL which i have specified in my code snippet."

注意:文本类似于评论,并且发布此评​​论应该发布在该单元格中的特定图像上.

NOTE: The text is like a comment and posting this comment that should post on particular image in that cell.

我复制了下面的代码片段.我还附上一张图片来解释一下.

I have copied the code snippet below. I have also attached an image to explain.

-(IBAction)postAction:(id)sender

{

    int index=[sender tag];

    homecell *cell = [[homecell alloc] init];

    UITextField *txt_c =(UITextField *)[cell.txt_comment viewWithTag:index];

    NSLog(@"jj %@",txt_c);

    gen_data *ut1=[[gen_data alloc]init];

    gen_data *ut=[gen_data getInstance];

}

推荐答案

你应该先了解一些 iOS 编程的基础知识.

You should get some basics of iOS programming first.

为什么要创建一个与 UITableView 无关的全新自定义单元格?当你以这种方式创建它时,它就是一个全新的 UITableViewCell.您应该先将其连接到它,获取它的 NSIndexPath 然后对其进行操作并做您想做的事情.

Why are you creating a totally new custom cell that is irrelevant to your UITableView? When you create it that way, it's a totally new UITableViewCell. You should connect it to it first, get its NSIndexPath and then operate with it and do what you want.

顺便说一句,如果你想查看 UITextfield 的文本,你应该 NSLog myTextField.text

BTW, if you want to see the text of UITextfield you should NSLog myTextField.text

您可以轻松编写viewWithTag:sender.tag,无需在此处创建额外的ivar

And you could easily write viewWithTag:sender.tag, no need to create an extra ivar here

这篇关于如何从表格视图的自定义单元格内的 TextField 获取值(标签)以发布到 te URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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