0
나는 30 개의 행을 가진 tableView를 가지고 있고 tableview의 상단에 View (Tableview 헤더에 없음)가 있는데, 다음을 포함하여 화면의 전체 스크린 샷을 캡처하고 싶습니다. 보기 및 tableview 모든 행을 있지만 tableview 및보기의 보이는 행을 캡처 할 수 있습니다. 도와주세요 및 사전에 감사드립니다. 여기 내 코드와 시뮬레이터의 스크린 샷이 있습니다. 주 (나는 우리가보기가 고정되어 왜있는 tableview 먹으 렴을 스크롤 할 때 그것은 또한 스크롤 때문에있는 tableview 헤더로 내보기를 원하지 않는)완전한 tableView ios의 스크린 샷을 캡쳐하는 방법
- (void)viewDidLoad {
[super viewDidLoad];
_myTableView.delegate = self;
_myTableView.dataSource = self;
UIBarButtonItem *next = [[UIBarButtonItem alloc]initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(nextButtonAction)];
UIBarButtonItem *screenShot = [[UIBarButtonItem alloc]initWithTitle:@"Screenshot" style:UIBarButtonItemStylePlain target:self action:@selector(screenshotButtonAction)];
self.navigationItem.leftBarButtonItem = screenShot;
self.navigationItem.rightBarButtonItem = next;
}
-(void)nextButtonAction
{
NextViewController *myVc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil]instantiateViewControllerWithIdentifier:@"NextViewController"];
NSLog(@"value of image is %@",viewImage);
myVc.myImage = viewImage;
[self.navigationController pushViewController:myVc animated:YES];
}
-(void)screenshotButtonAction
{
UIView *viewToRender = self.myTableView;
CGPoint contentOffset = self.myTableView.contentOffset;
UIGraphicsBeginImageContext(viewToRender.bounds.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(ctx, 0,-contentOffset.y); //-contentOffset.y
[viewToRender.layer renderInContext:ctx];
viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 30;
}
- (UITableViewCell)tableView:(UITableView)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *myString = @"reused";
UITableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:myString];
if (Cell == nil)
{
Cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:myString];
}
Cell.textLabel.text = [NSString stringWithFormat:@"This is Cell %ld",indexPath.row];
return Cell;
}
에서 신속한 3이있는 ScrollView의 가능한 중복 : http://stackoverflow.com/questions/3539717/getting-a-screenshot-of-a-uiscrollview-including-offscreen -부분품 – Sealos