我正在开发使用iOS5和Xcode 4.3.3的应用程序。用户滑动时重新创建自定义单元格
我有一个UserTableViewController其为TableViewController通过使用CustomCell是的UITableViewCell的子类建立。到目前为止,一切都很好。
我也实现了这两种方法来获取用户滑动。目前,我可以在用户滑动时显示删除按钮。
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSDictionary *dictionaryWithUrl = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"Urls" ofType:@"plist"]];
NSString *baseUrl = [dictionaryWithUrl objectForKey:@"urlWithNews"];
baseUrl = [baseUrl stringByAppendingFormat:@"/delete?newsId=%d",[[[self.arrayWithUserNews objectAtIndex:indexPath.row]objectForKey:@"newsId" ]intValue]];
NSURLRequest *requestToDeleteNews = [NSURLRequest requestWithURL:[NSURL URLWithString:baseUrl]];
[NSURLConnection sendSynchronousRequest:requestToDeleteNews returningResponse:nil error:nil];
[self.arrayWithUserNews removeObjectAtIndex:indexPath.row ] ;
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView reloadData];
}
}
那么,我想要做的是重新创建自定义单元格后,刷卡具有其他功能。因为,对于我正在开发的应用程序来说,删除单元格是不够的。用户也可以编辑表格单元格。这里是一个例子,我想创建。这是Twitter的iOS应用程序example.They做了我所需要的。
初始细胞
用户刷卡
关注后,仅仅是明确的,他们似乎完全一样的位置。
有没有人可以给我正确的道路来实现这个目标?
谢谢。
哇,这正是我需要的。非常感谢。 – limon 2012-08-01 16:35:53