웹에서 .txt 파일을 가져 와서 2 차원 배열로 파싱하는 앱을 작성하고 있습니다 (실제로는 각 요소의 NSArray가있는 NSMutableArray입니다). UITableView의 NSArray (하위 레이블을 사용하여 각 NSArray를로드). 나는 (16의 지수) 응용 프로그램 충돌 ... 17 셀에 아래로 스크롤하면17th uitableviewcell에 도달하면 앱이 다운 됨
어쨌든,
jQuery과는 (테스트 용) 483 개 세포를해야한다,하지만 난 과거를 스크롤 할 수없는 것 그것없이 16 번째 셀.
편집 코드와 오류를 게시하려면 :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
[[tableView layer] setCornerRadius:3.0];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"identifier"]autorelease];
}
NSInteger artistIndex = 1;
NSInteger albumIndex = 3;
NSInteger dateIndex = 6;
NSInteger imageIndex = 5;
// ARTIST
CGRect frame = CGRectMake(59, 11, 244, 13);
UILabel *label = [[UILabel alloc]initWithFrame:frame];
label.font = [UIFont boldSystemFontOfSize:13];
label.textColor = [UIColor blackColor];
label.text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:artistIndex];
[cell addSubview:label];
// ALBUM (more like description...
frame = CGRectMake(60, 30, 244, 11);
label = [[UILabel alloc]initWithFrame:frame];
label.font = [UIFont boldSystemFontOfSize:11];
label.textColor = [UIColor darkGrayColor];
label.text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:albumIndex];
[cell addSubview:label];
// DATE
frame = CGRectMake(59, 49, 244, 10);
label = [[UILabel alloc]initWithFrame:frame];
label.font = [UIFont fontWithName:@"Helvetica" size:10.0];
label.textColor = [UIColor darkGrayColor];
label.textAlignment = UITextAlignmentRight;
label.text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:dateIndex];
[cell addSubview:label];
// IMAGE
NSString *urlString = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:imageIndex];
NSData *urlData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]];
UIImage *myImage = [[UIImage alloc]initWithData:urlData];
UIImageView *myImageView = [[UIImageView alloc] init];
myImageView.image = myImage;
myImageView.frame = CGRectMake(8,9,44,44);
[myImageView.layer setMasksToBounds:YES];
[myImageView.layer setCornerRadius:3.0];
[[cell contentView] addSubview:myImageView];
[urlData release];
[myImage release];
[myImageView release];
[label release];
return cell;
참고 :이 코드는 꽤 끔찍한처럼 나는 너희들이 그것을 청소하기 위해 어떤 제안이 있다면, 내가 듣고 싶네요 ... 느낌 그것.
- '경계를 넘어 인덱스 (6) [0 .. 3] [NSMutableArray를 objectAtIndex :] *' 응용 프로그램을 종료* 인해 캐치되지 않는 예외 'NSRangeException', 이유에 :
그리고 여기에 오류 메시지입니다
최소한의 예제는 문제를 이해하는 데 유용합니다. –
충돌 할 때받은 로그 문을 게시 할 수 있습니까? –
데이터 소스 메소드와 관련이있는 것처럼 보입니다. 이 방법 중 충돌을 일으키는 라인은 어느 것입니까? 난 당신의 문제가 다른 곳에서, 아마도 당신이 섹션이나 테이블 뷰의 행 수를 결정하는 방법에 거짓말을 느낌이있다. – Rog