0

我正在对 .mm 文件进行屏幕截图我使用了以下代码,我尝试了 2 种方式它不起作用。如果我将相同的代码放在我的任何一个 .m 文件中,它的工作原理

- (void)viewWillAppear:(BOOL)animated
{
 UIGraphicsBeginImageContext(self.view.bounds.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    appDelegate.convertedImage=image;
UIGraphicsEndImageContext();
}

         (or)

-(void)viewWillAppear:(BOOL)animated
{
CGSize newSize = CGSizeMake(320, 416);//377
    UIGraphicsBeginImageContext(newSize);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    appDelegate.convertedImage=viewImage;
}

它不适用于 .mm 是否有其他选择?(我在我的项目中集成了 openCv,我使用了 1 个 .mm 文件)

请指导我

提前致谢

4

1 回答 1

0

viewWillAppear 方法在视图渲染之前调用,所以没有什么可以捕获的。您是否尝试过使用 viewDidAppear 代替?

一些参考

于 2012-10-23T07:33:20.083 回答