【发布时间】:2012-12-14 22:28:32
【问题描述】:
我有一个填充列表的文本项列表。它的代码如下所示:
// CREATING EACH CELL IN THE LIST
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"business";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(!cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:17];
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
}
cell.textLabel.text = [cellTitleArray objectAtIndex:indexPath.row];
// CLOSE THE SPINNER
[spinner stopAnimating];
// return the cell for the table view
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIFont *cellFont = [UIFont fontWithName:@"Helvetica" size:17];
CGSize constraintSize = CGSizeMake(self.itemList.frame.size.width, MAXFLOAT);
CGSize labelSize = [[cellTitleArray objectAtIndex:indexPath.row] sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
return labelSize.height + 30;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
我想做的是让这个人选择编辑每个项目。一种有意义的方法是将其设置为 2 列列表,并在右侧列中创建一个类似“>”的字符,这样他们就可以点击它,它会给他们一个编辑项目的选项。
在这种情况下怎么做?
谢谢!
【问题讨论】:
-
嗯...当点击一行时,didSelectRowAtIndexPath 被调用,所以只需要让用户在那里编辑该行吗?查看表格视图的编辑模式。或者你想要一个自定义的编辑视图(比如另一个编辑屏幕)
-
@yuf 我想给他们一个选项,比如“你确定要编辑这个部分吗?”如果他们说是,我会把他们带到屏幕上。那是笨拙的用户体验吗?
标签: ios uitableview ios5