2012-08-01 51 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

相關問題