如何在iPhone SDK中使tableviewcell文本在触摸时可编辑? [英] How to make tableviewcell text editable on touch in iPhone SDK?

查看:83
本文介绍了如何在iPhone SDK中使tableviewcell文本在触摸时可编辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程序中,我有一个表格视图.

In my iPhone app, I have a table view.

我希望当用户在表格视图的单元格上选择(或基本触摸)时,他/她应该能够编辑单元格内容.

I want that when the user selects (or basically touches) on the cell of the tableview then he/she should be able to edit the cell contents.

我该怎么做?

推荐答案

@PARTH为了使您的UITableView单元格可编辑,我建议您给您的单元格添加文本字段....

@PARTH in order to make your UITableView cells editable i suggest u to give textfields to your cell....

例如:-在

-(UITableViewCell *)reuseTableViewCellWithIdentifier:(NSString *)identifier withIndexPath:(NSIndexPath *)indexPath {


    CGRect cellRectangle = CGRectMake (0, 10, 300, 70); 
    CGRect Field1Frame = CGRectMake (10, 10, 290, 70);
    UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:cellRectangle reuseIdentifier:identifier] autorelease];
    UITextField *textField;


    //Initialize Label with tag 1.

    textField = [[UITextField alloc] initWithFrame:Field1Frame];

    textField.tag = 1;
    [cell.contentView addSubview:textField];

[textField release];
    return cell;
}

并在您的cellForRowAtIndexPath方法中//配置单元格.

and in your cellForRowAtIndexPath method // Configure the cell.

 UITextField *txtTemp = (UITextField *)[cell.contentView viewWithTag:1];

在您希望在表视图中的相应位置使用此功能,否则将其隐藏.....希望它将对您有帮助!

use this where u want in your tableview accordingly otherwise hide it.....Hope it will help u!!

这篇关于如何在iPhone SDK中使tableviewcell文本在触摸时可编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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