2011-01-05 78 views
5

我看了,我似乎無法找到任何地方在堆棧溢出一些有我一樣的問題。所以我用下面的代碼:刷卡刪除

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete); 
} 

,當我刷卡出現刪除按鈕,按下但是當它沒有做任何事情,我都忘了怎麼辦?

回答

10

您需要在if聲明後實際刪除您的數據。目前,您的if聲明根本沒有任何效果,因爲它只是後面有一個分號。

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete) 
    { 
     //Code to delete data goes here. 
     //This could include removing an object from an array, deleting it from core data, 
     //and removing the selected row. 
    } 
} 
+0

歡呼聲,現在像一個魅力 – 2011-01-05 19:47:44

+0

很高興我能幫上忙。如果一切正常,不要忘記標記「已接受」。 :) – GendoIkari 2011-01-05 21:58:30

+1

你知道,我本可以解決這個問題,但通常情況下,首先看這裏是非常簡單的。偉大的,簡單的答案,它的出色表現。 – PKCLsoft 2012-07-25 03:28:05