我正在開發使用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