2012-04-17 73 views
0

我想要在我滑動並點擊桌面視圖上的刪除按鈕時有一個提醒確認。 基本上我想告訴警報彈出,點擊「OK」,並與發送數據前「取消」按鈕:在桌面視圖上刪除提醒確認

[[ConnectionSingleton getInstance] sendData:[NSString stringWithFormat:@"modifOrderFoodState::%@::%@::%@", [cellOrder objectForKey:@"orderFoodRelId"], state, [ConnectionSingleton getInstance].restaurantId] ]; 

,如果取消按鈕客戶點擊,abord發送數據的功能。

這是我的代碼:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 

NSMutableDictionary *cellOrder = [orders objectAtIndex:indexPath.row]; 
NSString *state = @"4"; 

if (editingStyle == UITableViewCellEditingStyleDelete) { 


    [[ConnectionSingleton getInstance] sendData:[NSString stringWithFormat:@"modifOrderFoodState::%@::%@::%@", 
               [cellOrder objectForKey:@"orderFoodRelId"], 
               state, 
               [ConnectionSingleton getInstance].restaurantId] ]; 
    }  
} 

感謝

回答

1

使此一等級UIAlertViewDelegate。樣式爲刪除時創建一個UIAlertView。將發送數據代碼移動到alertView:clickedButtonAtIndex:方法中,並在用戶單擊確定時運行它。

+0

感謝您的工作,但我得到了我以前得到的index.path.row元素的問題。 如何獲取當前行索引? – socrateisabot 2012-04-17 16:49:42

+0

您可以將行保存爲對象中的屬性,也可以將cellOrder屬性設置爲屬性,然後顯示警報。 (或者在表視圖上調用indexPathForSelectedRow。) – 2012-04-17 16:56:27