0
앱이 정상적으로 작동하고 충돌이 발생합니다. 크래시가 메모리를 정리하고 클린 런이 메모리를 손상시키는 것처럼 보입니다.내 iPhone 시뮬레이터가 계속 충돌합니다. 실행합니다.
나는 그것이 메모리 할당과 관련이 있다고 생각하지만 확실하지 않습니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyStateCell";
static NSString *MyNib = @"StateCell";
StateCell *cell = (StateCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
UIViewController *c = [[UIViewController alloc] initWithNibName:MyNib bundle:nil];
cell = (StateCell *)c.view;
[c autorelease];
}
// Configure the cell.
NSString *cellAnswerName = [[NSString alloc] initWithFormat:@""];
cellAnswerName = [theQuizArray objectAtIndex:indexPath.row];
int theStatusCode = [[theResultArray objectAtIndex:indexPath.row] intValue];
NSString *statusString;
NSString *pointsWon;
if(theStatusCode == 0){
statusString = [NSString stringWithFormat:@""];
pointsWon = [NSString stringWithFormat:@""];
}else if(theStatusCode == 12){
statusString = [NSString stringWithFormat:@"Wrong"];
pointsWon = [NSString stringWithFormat:@"0"];
}else if(theStatusCode == 11){
statusString = [NSString stringWithFormat:@"Out of time"];
pointsWon = [NSString stringWithFormat:@"0"];
}else{
int elapsedTime = 10 - theStatusCode;
int pointsWonInt = 10 * theStatusCode;
pointsWon = [NSString stringWithFormat:@"%i", pointsWonInt];
if(elapsedTime == 1){
statusString = [NSString stringWithFormat:@"%i second", elapsedTime];
}else{
statusString = [NSString stringWithFormat:@"%i seconds", elapsedTime];
}
}
NSString *imagePath = [[@"State_" stringByAppendingString:cellAnswerName] stringByAppendingString:@".png"];
UIImage *image = [UIImage imageNamed:imagePath];
[[cell stateImage] setImage:image];
[[cell stateName] setText:cellAnswerName];
[[cell stateResult] setText:statusString];
[[cell statePoints] setText:pointsWon];
if([statusString isEqualToString:@"Wrong"])
[[cell stateResult] setTextColor:[UIColor redColor]];
return cell;
} 꽤 기괴한
항상 빌드 및 실행 – Bryan
사용자 지정 처리를 수행하지 않습니다. 텍스트 파일에 데이터를로드하기 만하면됩니다. 미친 일이 없습니다. 귀하의 답변에 감사드립니다 bbum – Bryan
귀하의 cellForRowAtIndexPath 메서드 – Jordan