아마도 셀을 두드린 후 적절한 두 위치에이 두 로직을 묶어야합니다. 현재 셀의 CGRect
을 얻는 방법은 - (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath;
입니다.
- 클릭하면
UITableViewCell
의 CGRect
을 찾습니다.
몇 개조하면 되겠 어해야 할 수도 있습니다,
이이 문제를 해결해야
-(UIImage *) screenshot:(CGRect)cellRect onCell:(UITableViewCell)cell
{
UIGraphicsBeginImageContext(cellRect.size);
CGContextRef context=UIGraphicsGetCurrentContext();
[cell.layer renderInContext:context];
UIImage *image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
1 단계의
CGRect
에서
CGSzie
를 가져옵니다.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIImageView *imageV = [[UIImageView alloc]initWithImage:[self screenshot:[tableView rectForRowAtIndexPath:indexPath] onCell:[tableView cellForRowAtIndexPath:indexPath]]];
imageV.frame = CGRectMake(0, 75, self.tableView.frame.size.width,100);
UIViewController *viewController = [[UIViewController alloc]init];
[viewController.view addSubview:imageV];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:viewController];
[self presentViewController:nav animated:YES completion:^{
}];
}
화면 : 여기서
가 사용하다 선택된 1 행
새로운 뷰 컨트롤러에 이미지보기 부하
잘 작동합니다 ... !!!! –
여기에서 컨텍스트는 두 번째 셀을 탭한 경우에도 첫 번째 셀의 이미지 만 가져옵니다. –
@MonishKumar 정말로 이것이 문제입니까? –