2012-08-01 63 views
0

我正在开发使用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做了我所需要的。

初始细胞


用户刷卡

enter image description here

关注后,仅仅是明确的,他们似乎完全一样的位置。

有没有人可以给我正确的道路来实现这个目标?

谢谢。

回答

0

退房this project

这不正是ü希望

+0

哇,这正是我需要的。非常感谢。 – limon 2012-08-01 16:35:53

0

单元格没有被删除,它只是在其上显示另一个视图。您需要创建一个自定义单元格,对其进行子类化,然后才能识别横向手势。当您检测到手势时,请更改单元格显示的视图。

+0

我怎么能知道哪个小区刷卡到其视图切换到另外一个呢? – limon 2012-08-01 14:38:41

+0

你会在单元格子类中执行它,而不是在表委托方法中 – Dustin 2012-08-01 14:41:28

+0

好吧,我想我明白了。谢谢一堆 – limon 2012-08-01 14:47:38

相关问题