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

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

问题描述

我希望我的iOS应用程序将用户输入的文本传递给URL。相关代码粘贴在下面。当我运行应用程序时,文本不会被赋予任何值。它保持为null。

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 OS版本: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.

BTW,如果你想查看UITextfield的文本,你应该 NSLog myTextField。文字

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获取值(标签)以在URL上发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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