커스텀 테이블 셀을 클릭했을 때 이미지를 표시하기 위해 다음 코드를 사용했습니다. 그러나 검은 화면을 클릭하면 테이블보기로 돌아 가지 않고 검은 색 화면도 표시됩니다. 사전ImageView가 uitable로 돌아 오지 않습니다.
1
A
답변
1
에서
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomTableViewCell *cell = tableView.visibleCells[indexPath.row];
UIViewController *imageVC = [UIViewController new];
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
imageVC.view.frame = CGRectMake(0, 0, screenWidth, screenHeight);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:imageVC.view.frame];
cell.vendorImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:fullImg]]];
// cell.imageView.image = fullImg;
imageView.image = cell.vendorImage.image;
imageView.userInteractionEnabled=YES;
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:imageView.hidden=YES];
[imageView addGestureRecognizer:tapGR];
[self presentViewController:imageVC animated:YES completion:nil];
}
덕분에 당신은 imageVC
에 이미지를 추가하지 않습니다. 검정색 인 빈보기 컨트롤러를 표시하고 있습니다.
UIViewController
의 하위 클래스를 만들어야합니다. 보기 컨트롤러에 NSImage
속성을 추가하십시오. 클래스에 이미지보기를 추가하고 loadView
(또는 인터페이스 작성기 파일 (xib 또는 스토리 보드))에서 초기화하십시오.
- (void)loadView {
UIView *contentView = [[UIView alloc] initWithFrame:...];
self.imageView = [[UIImageView alloc] initWithFrame:...];
[contentView addSubview:self.imageView];
self.view = contentView;
}
viewWillAppear:
의 이미지보기로 설정하십시오.
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.imageView.image = self.image;
}
닫기 닫기를 클릭하십시오.
- (void)dismiss {
[self dismissViewControllerAnimated:YES completion:nil];
}
는 다음과 같이 뷰 컨트롤러를 제시 :
MyImageViewController *imageVC = [[MyImageViewController alloc] init];
cell.vendorImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:fullImg]]];
imageVC.image = cell.vendorImage.image;
imageView.userInteractionEnabled=YES;
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)];
[imageView addGestureRecognizer:tapGR];
[self presentViewController:imageVC animated:YES completion:nil];
0
당신의 UIView를 사용할 수 있으며 테이블보기 위의 현재보기에이보기를 추가 할 수 있으며, 추가하는 대신 새의 UIViewController를 만들기위한 필요 없음 그것 위로 이미지보기.
+0
어떤 샘플 코드로 도울 수있다. –
관련 문제
- 1. 재귀 함수가 돌아 오지 않습니다.
- 2. 스택 팝업이 돌아 오지 않습니다.
- 3. MongoDB Primary가 돌아 오지 않습니다.
- 4. 프롬프트가 다시 돌아 오지 않습니다.
- 5. 아파치가 돌아 오지 않는다
- 6. Typhoeus가 응답 본문으로 돌아 오지 않습니다.
- 7. 똑같은 문자열이 참으로 돌아 오지 않습니다.
- 8. 데이터베이스의 쿼리가 레일로 돌아 오지 않습니다.
- 9. MVC보기 페이지가 컨트롤러로 돌아 오지 않습니다.
- 10. 페이팔이 설정에 지정된 URL로 돌아 오지 않습니다.
- 11. 클릭하면 jquery 애니메이션이 돌아 오지 않습니다
- 12. 대화 상자의 단추가 뒤로 돌아 오지 않습니다.
- 13. 서블릿이 이전 페이지로 돌아 오지 않습니다.
- 14. Play 인앱 결제가 애플리케이션으로 돌아 오지 않습니다.
- 15. 스레딩 문제 : 호출자에게 제어가 돌아 오지 않습니다.
- 16. ASMX 웹 서비스가 jQuery로 돌아 오지 않습니다.
- 17. 안드로이드 MediaPlayer가 prepareAsync에서 돌아 오지 않습니다.
- 18. Google지도 SDK는 길을 돌아 오지 않습니다
- 19. aspx 페이지에서 이미지가 돌아 오지 않습니다.
- 20. 파이썬에서 xmlrpc 클라이언트 호출이 돌아 오지 않습니다.
- 21. 스레드가 SwingUtilities.invokeLater에서 메인 스레드로 돌아 오지 않습니다.
- 22. HttpClient GetStringAsync - 결코 돌아 오지 않습니다.
- 23. 페이 스북 api가 돌아 오지 않습니다. Comments
- 24. Firebase 데이터 검색이 산발적으로 돌아 오지 않습니다.
- 25. pf_ring과 libpcap if_index가 돌아 오지 않습니다.
- 26. Facebook SSO IOS가 앱으로 돌아 오지 않습니다.
- 27. 일련의 특성이 올바른 개체로 돌아 오지 않습니다.
- 28. UITableViewCell ImageView가 업데이트되지 않습니다.
- 29. java.util.Scanner가 프롬프트로 돌아 오지 않음
- 30. 페이지에서 돌아 오지 않음 'INavigationAware.OnNavigatedTo`
컨트롤러를보기 위해 subView로 imageView를 추가하지 않았습니다. – Injectios
귀하의 작업은 선택기 여야하며 그렇게 사용할 수 없으며 미리보기 이미지를 표시하는 좋은 방법은 아닙니다. – BoranA
imageView와 imageVC의 관계는 무엇입니까? imageVC에 imageView를 추가 하시겠습니까? – jailani