iOS開發學習之#表視圖#(1)刪除行

好久木有寫博客了,前面學習的表視圖其他內容都木有寫,今天就從刪除行開始吧,希望自己能夠堅持下去。。加油↖(^ω^)↗。。廢話少說吧,,,直接上代碼:


下面是刪除行的核心代碼:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
    if (editingStyle ==UITableViewCellEditingStyleDelete) {
        [aremoveObjectAtIndex:indexPath.row];
        [tvdeleteRowsAtIndexPaths:[NSArrayarrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }
}



當然要實現刪除行這一功能前,要實現遵守delegate協議:

@interface ViewController :UIViewController<UITableViewDataSource,UITableViewDelegate>{
    IBOutletUITableView *tv;
    NSMutableArray *a;
    NSArray *b;
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章