Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 屏幕捕获超出屏幕范围_Objective C_Uiimage_Calayer_Uigraphicscontext - Fatal编程技术网

Objective c 屏幕捕获超出屏幕范围

Objective c 屏幕捕获超出屏幕范围,objective-c,uiimage,calayer,uigraphicscontext,Objective C,Uiimage,Calayer,Uigraphicscontext,我使用UIGraphicsBeginImageContextWithOptions来获取当前显示的屏幕UITable的屏幕抓取 这是我的密码: UIGraphicsBeginImageContextWithOptions(self.view.frame.size, self.view.opaque, 0.0); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsG

我使用UIGraphicsBeginImageContextWithOptions来获取当前显示的屏幕UITable的屏幕抓取

这是我的密码:

UIGraphicsBeginImageContextWithOptions(self.view.frame.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
然后我使用图像对象作为屏幕抓取

我的问题是,我想屏幕抓取包括额外的100像素的当前未显示的数据,它将显示,如果我向下滚动

我该怎么做

- (IBAction) renderScrollViewToImage
 {
   UIImage* image = nil;

   UIGraphicsBeginImageContext(_scrollView.contentSize);
  {
    CGPoint savedContentOffset = _scrollView.contentOffset;
    CGRect savedFrame = _scrollView.frame;

    _scrollView.contentOffset = CGPointZero;
    _scrollView.frame = CGRectMake(0, 0, _scrollView.contentSize.width, _scrollView.contentSize.height);

    [_scrollView.layer renderInContext: UIGraphicsGetCurrentContext()];     
    image = UIGraphicsGetImageFromCurrentImageContext();

    _scrollView.contentOffset = savedContentOffset;
    _scrollView.frame = savedFrame;
   }
  UIGraphicsEndImageContext();

if (image != nil) {
    [UIImagePNGRepresentation(image) writeToFile: @"/tmp/test.png" atomically: YES];
    system("open /tmp/test.png");
  }
}

参考

但这将捕获整个内容。我只想要当前可见的+100像素。另外,我会将此添加到我正在使用UITable的描述中。