首页 > 其他 > 详细

cell

时间:2015-11-06 00:11:17      阅读:292      评论:0      收藏:0      [点我收藏+]
 *  监听到cell点击选中后会调用的方法
 *
*/
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
//    0.取得点击的cell(第一种方式)
//    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

  
//    1.创建一个弹框
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
//    2.让弹框中出现一般的textFeild
    alert.alertViewStyle =  UIAlertViewStylePlainTextInput;
//     2.1取得textFeild
    UITextField *nameTextFeild = [alert textFieldAtIndex:0];
    alert.tag = indexPath.row;
//     2.2把对应的cell中的名称赋值给nameTextFeild
//    nameTextFeild.text = cell.textLabel.text;
     HeroModel *hero =  self.heros[indexPath.row];
     nameTextFeild.text = hero.name;
    self.tableView.delegate = self;
//    3.弹出
    
    [alert show];
    
    
}
/**
 *  监听到alertView中按钮的点击调用的方法
 *
 
 */
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    
//    1.修改模型
      HeroModel *hero =  self.heros[alertView.tag];
//     1.1取得文字
    
    
    hero.name = [alertView textFieldAtIndex:0].text;
    
//    2.刷新数据
//    [self.tableView reloadData];//全局刷新
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:alertView.tag inSection:0];
//      2.1局部刷新
    [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
    
    
    
    
    
    
    
    
}

 

cell

原文:http://www.cnblogs.com/gp886/p/4941048.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!