JSON을 통해 제품 ID를 구문 분석 한 다음 세부 정보보기로 푸시하고 URL에 넣어 선택한 제품에 대한 자세한 정보를 구문 분석하지만 didSelectRowAtIndexPath
은 잘못된 색인 경로를 반환합니다. 제품이로드되지 않은 행 마지막으로 검색된 행의 제품 ID를 가져옵니다.didSelectRowAtIndex에 대한 잘못된 indexPath
예를 들어 5 행이 표시됩니다. 내 논리는 각 행 (행 1, 행 2, 행 3, 행 4, 행 5)에 대해 모든 ID를 올바르게 구문 분석합니다. 행 1에 연결된 정보를 얻고 싶기 때문에 행 1의 정보 대신 상세 뷰가 행 5에 대한 정보를 구문 분석하는 명령을 얻습니다. 왜냐하면 그 행의 마지막 ID가 구문 분석 된 후 표시됩니다. 잘못된 정보.
didSelectRowAtIndexPath
메서드가 올바른 행에 대한 올바른 정보를 얻는 방법을 모르겠다.
여기 didSelectRowAtIndexPath
내 코드입니다 :
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIStoryboard *iPhone = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
CJArtikelDetailViewController *artikelView = [iPhone instantiateViewControllerWithIdentifier:@"detail"];
NSString *detail = [NSString stringWithFormat:@"%@", wareID];
artikelView.productID = detail;
[self.navigationController pushViewController:artikelView animated:YES];
[neuheitenTableView deselectRowAtIndexPath:indexPath animated:YES];
NSLog(@"IndexPath: %@", [indexPath description]);
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *neuheitenCell = @"neuheitenCell";
CJHomeTableCell *cell = [tableView dequeueReusableCellWithIdentifier:neuheitenCell];
/*
NSNumber *preis = [[arrayArtikelPreis objectAtIndex:indexPath.row] objectForKey:@"preis"];
NSMutableString *test = [NSMutableString stringWithFormat:@"€ %@", preis];
cell.artikelPreis.text = test;
*/
NSString *imageString = [[arrayNeuheiten objectAtIndex:indexPath.row] objectForKey:@"bild"];
//NSLog(@"BildURL: %@", imageString);
NSURL *imageURL = [NSURL URLWithString:imageString];
[cell.artikelImage setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@""]];
NSDictionary *object = [arrayNeuheiten objectAtIndex:indexPath.row];
//NSLog(@"%@", object);
wareID = [object objectForKey:@"ware_id"];
NSLog(@"Waren ID: %@", wareID);
cell.artikelName.text = [object objectForKey:@"name"];
cell.artikelHersteller.text = [object objectForKey:@"lieferant_name"];
return cell;
}
나는 방법은 어떻게 든 선택했지만, 난 방법을 모르고 워드 프로세서에 대한 정보를 찾을 수있는 행을 결정해야한다.
미리 도움을 청하십시오!
indexPath.row 당신을 위해 작동하지 않았다 도움이? –
indexPath.row 어디서? –
웨어는 무엇입니까? wareid에 값을 할당 할 코드를 게시 할 수 있습니까 –