다음 코드는 응용 프로그램을 충돌시키고 그 이유를 모르겠습니다. 그것은 불규칙하게 충돌합니다. 즉, 행을 클릭 할 때 이미지보기를 예를 들어 30 번 표시 할 수 있으며 때로는 행을 선택할 때 두 번 째로 나타납니다.스레딩 문제 (EXC_BAD_ACCESS)
FYI : 활동 표시기, 작업 시트 및 변수 imageNr은 전역으로 정의되며 viedDidLoad 메소드에서 초기화됩니다.
미리 조언 해 주셔서 감사합니다.
숀
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
imageNr = indexPath.row + 1;
activityLoadView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(-17.5, -11, 35, 35)];
activityLoadView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
activityLoadView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
actionSheetLoadView = [[UIActionSheet alloc] initWithTitle:@""
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
actionSheetLoadView.actionSheetStyle = UIBarStyleBlackOpaque;
[actionSheetLoadView setMessage:[NSString stringWithFormat:@"\n\n\n\n\n\n\n\n\n\n\n\n\nLoading image ..."]];
[actionSheetLoadView addSubview:activityLoadView];
[actionSheetLoadView showInView:self.view];
[actionSheetLoadView setBounds:CGRectMake(0,0,320,720)];
[activityLoadView performSelector:@selector(startAnimating) withObject:nil afterDelay:0.1];
[self performSelectorInBackground:@selector(showImageView) withObject:nil];
}
- (void)showImageView
{
[self setViewInfo];
[self.navigationController pushViewController:imageViewController animated:YES];
[activityLoadView performSelector:@selector(stopAnimating) withObject:nil afterDelay:0.1];
[actionSheetLoadView dismissWithClickedButtonIndex:0 animated:YES];
[activityLoadView release];
[actionSheetLoadView release];
}
답변 해 주셔서 감사합니다. 문제는 [self performSelectorOnMainThread : @selector (showImageView) withObject : nil waitUntilDone : NO]를 사용하는 경우입니다. 이미지가 완전히로드되기 전에 이미지가로드되는 동안 작업 시트가 표시되지 않습니다. – Sean
@Sean : 이미지 로딩의 병목 현상은 무엇입니까? 단순히 보이지 않는 뷰에 이미지를로드하는 경우 백그라운드 스레드에서 이미지를로드 한 다음 이미지 뷰를 디스플레이에 추가하고 UI 업데이트의 나머지 부분을 수행하는 주 스레드에서 수행되는 콜백을 수행하십시오. –
안녕하세요, 문제는 이미지를로드하지 않는 것입니다 (이미지 및 이미지의 레이블 텍스트는 -setViewInfo 메서드에서 설정됩니다), 이미지가로드되는 동안 액션 뷰가 더 많이 표시됩니다. 걸립니다. 내가 뭐라는지 알 겠어? – Sean