码迷,mamicode.com
首页 > 移动开发 > 详细

iOS开发学习之#表视图#(1)删除行

时间:2014-12-01 15:58:03      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:ios开发   表视图   删除行   

好久木有写博客了,前面学习的表视图其他内容都木有写,今天就从删除行开始吧,希望自己能够坚持下去。。加油↖(^ω^)↗。。废话少说吧,,,直接上代码:


下面是删除行的核心代码:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{

    if (editingStyle == UITableViewCellEditingStyleDelete) {

        [a removeObjectAtIndex:indexPath.row];

        [tv deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

    }

}


当然要实现删除行这一功能前,要实现遵守delegate协议:

@interface ViewController : UIViewController<UITableViewDataSource, UITableViewDelegate>{

    IBOutlet UITableView *tv;

    NSMutableArray *a;

    NSArray *b;

}


iOS开发学习之#表视图#(1)删除行

标签:ios开发   表视图   删除行   

原文地址:http://blog.csdn.net/u010710758/article/details/41648225

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!