如何查找/删除UITableViewCell的CUSTOM行详细信息 [英] How to find/ delete the CUSTOM row detail of UITableViewCell
问题描述
这个问题与我之前的问题有点相关
我是iPhone应用程序的新手并试图学习 UITableView
使用 JSON
。我跟着
< a href =http://www.cocoawithlove.com/2009/01/multiple-row-selection-and-editing-in.html\"rel =nofollow>多行选择和编辑在
This question is bit related to my earlier question
I am newbie for iPhone application and trying to learn UITableView
with JSON
. I followed this video
for learning.
I created same example using Stoaryboard and also added new screen where I can add data. Now I was trying to delete the data. So what I did is thought is instead of below method, I will add button on each row and on clicking of that I will delete the data.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
But I am not getting how I will get the row details and how to delete.
Any help/ suggestion would be grateful.
Below is how my screen looks like.
Note:
The UITableViewCell
is of CUSTOM type.
Update the data model according to edit actions delete using bellow code.
This bellow code is just an example for hot to delete or remove the object from array and also from table .. for more info check the tutorial which i post the link bellow..
- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[arryData removeObjectAtIndex:indexPath.row];
[tblSimpleTable reloadData];
}
}
or also using this bellow logic with custom button of cell...
- (IBAction)deleteCustomCellWithUIButton:(id)sender
{
NSIndexPath *indexPath = [yourTableView indexPathForCell:(UITableViewCell *)[[[sender superview] superview] superview]];
NSUInteger row = [indexPath row];
[yourTableView removeObjectAtIndex:row];
[yourTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
For more info refer these tutorial...
这篇关于如何查找/删除UITableViewCell的CUSTOM行详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!