2014-02-06 1 views
0

아래 코드는 IOS 스 와이프가 기능을 삭제하도록하고 행을 삭제합니다. 문제는 기본 데이터 구조가 삭제되지 않는다는 것입니다. 3 개의 셀, Google-Bing-Yahoo가 있습니다. Google에서 셀 삭제를 삭제하지만 Bing이 위로 이동하면 indexPath.row 0이되고 Google의 이전 위치를 상속합니다. 어디에서 "이 셀에도 조치를 삭제하십시오"라는 메시지가 누락되었습니다. 아니면 세포가 할당 된 방법일까요? 태그를 사용해야합니까?삭제하려면 스 와이프가 기본 데이터 구조를 삭제하지 않습니다

////My Array 
someData = [[NSMutableArray alloc]init]; 
    [someData addObjectsFromArray:[NSMutableArray arrayWithObjects: @"Google", @"Bing", @"Yahoo", nil]]; 


////Allow cell editing & remove data 
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

// Remove the row from data model 
[someData removeObjectAtIndex:indexPath.row]; 

// Request table view to reload 
[tableView reloadData]; 

} 


////Cell Chosen Action 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 


     if(indexPath.row == 0) { 
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://google.com"]]; 
} 
     if(indexPath.row == 1) { 
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://bing.com"]]; 
} 
     if(indexPath.row == 2) { 
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://yahoo.com"]]; 
} 

답변

1

didSelectRowAtIndexPath는 행 0이 Google을 엽니 다. Google을 삭제하면 행 0이 빙빙 돌지 만 여전히 Google에 열어 둡니다.

기본적으로 배열의 이름과 함께 URL을 구성하므로 if 문과 혼란이 없어야합니다.

+0

의미가 있습니다. 그래서 그것은 나의 임무 방법이었다. 고맙습니다. – Jesse

관련 문제