2012-08-07 2 views
0

이 코드가 있는데 실제로 사용자가 삭제 메시지를 누르면 경고 메시지를 보내고 싶습니까 ?? 내가 그렇게 할 수있는 방법을 ..경고 메시지를받는 방법?

#pragma mark - 
#pragma mark Table Data Source Methods 

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 


    return [list count]; 

} 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    static NSString *DeleteMeCellIdentifier = @"DeleteMeCellIdentifier"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DeleteMeCellIdentifier]; 
    if (cell==nil) { 

     cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DeleteMeCellIdentifier]; 
        } 

    NSInteger row = [indexPath row]; 
    cell.textLabel.text = [self.list objectAtIndex:row]; 
    return cell; 

    } 

#pragma mark - 
#pragma mark Table View Data Source Methods 

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

    NSUInteger row = [indexPath row]; 
    [self.list removeObjectAtIndex:row]; 
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 


} 

답변

3

이 코드를 시도하십시오 :

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

if (editingStyle == UITableViewCellEditingStyleDelete){ 
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:[NSString 
    stringWithFormat:@"deleted row no. %@",indexPath.row] delegate:nil 
    cancelButtonTitle:@"Ok" otherButtonTitles: nil]; 
    [alert show]; 
    [alert release]; 
} 
} 
+0

감사합니다. 그 일 – developer

0

당신이 시도 할 수 있습니다 : 빠른 회신

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
    NSUInteger row = [indexPath row]; 
    [self.list removeObjectAtIndex:row]; 
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 

UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Alert" message:[NSString stringWithFormat:@"You have deleted row no. %@",indexPath.row] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil]; 
     [alert show]; 


}