lantianyiming 2013-04-03 02:52 采纳率: 0%
浏览 2974
已采纳

提出自定义单元中的textView内容

在我的表视图中包含一个自定义单元,其中有label和textView,我想提出textview的数据保存到feedBack按钮中,当添加txtView到数据数组中,得到重复的自定义cell。

这个问题应该怎么解决呢?请高手指教,谢谢。

- (void)textViewDidEndEditing:(UITextView *)textView
{
    FeedbackQuestionDC *feedBack = [dataArray objectAtIndex:textView.tag];
    feedBack.FeedbackQuestionDC_Answers=textView.text;
    [dataArray addObject:feedBack];
    [myTableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *simpleTableIdentifier = @"Feed Back";

    feedBackCC *cell = (feedBackCC *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
    if (cell == nil) {
        UIViewController *c = [[UIViewController alloc] initWithNibName:@"feedBackCC" bundle:nil];
        cell = (feedBackCC *) c.view;}
    cell.textLabel.font = [UIFont boldSystemFontOfSize:15.0];
    FeedbackQuestionDC *feedBack = [dataArray objectAtIndex:[indexPath row]];
         cell.lblQuestion.text = feedBack.FeedbackQuestionDC_QuestionText;
    cell.txtViewAnswer.tag=indexPath.row;
    cell.txtViewAnswer.text=feedBack.FeedbackQuestionDC_Answers;
    cell.txtViewAnswer.delegate=self;
    return cell;
}
  • 写回答

2条回答

  • ce_la_vie 2013-04-03 05:20
    关注
    - (void)textViewDidEndEditing:(UITextView *)textView
    {
       FeedbackQuestionDC *feedBack = [dataArray objectAtIndex:textView.tag];
       feedBack.FeedbackQuestionDC_Answers=textView.text;
       [dataArray addObject:feedBack]; //REMOVE THIS LINE 
       [myTableView reloadData];
    }
    

    移除上述代码中我建议的那行,不需要在数组中重复添加对象。在使用dataArray相关对象中已经更新过了。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序