【问题标题】:How to take screen shot in iOS device programmatically for SOS?如何以编程方式在 iOS 设备中为 SOS 拍摄屏幕截图?
【发布时间】:2016-11-05 20:34:43
【问题描述】:

使用新API之类的

snapshotViewAfterScreenUpdates
resizableSnapshotViewFromRect
drawViewHierarchyInRect

使用这些我想以任何格式拍照并需要发送。

【问题讨论】:

  • 由于 iOS 应用是沙盒化的,因此您只能对自己的应用进行截图。

标签: ios api screenshot photo send


【解决方案1】:

试试这个

UIView *screenshotView = [[UIScreen mainScreen] snapshotViewAfterScreenUpdates:NO];
UIImage *snapshotImage = [self imageFromView:screenshotView];

- (UIImage *)imageFromView:(UIView *)view
{
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0.0);
    [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return img;
}

【讨论】:

  • 这样我没有得到顶部的时间戳和信号强度!我能得到完整的屏幕截图吗?
  • @DheerajChahar 我已经编辑了我的答案,这将起作用
  • 我得到的图像太大。它的左上角有主屏幕。
  • 你能添加那个图片吗,我需要看看
  • 我在顶部添加了照片。请检查
猜你喜欢
  • 2023-04-02
  • 2016-03-18
  • 1970-01-01
  • 1970-01-01
  • 2011-01-13
  • 1970-01-01
  • 2023-03-19
  • 1970-01-01
  • 2023-03-04
相关资源
最近更新 更多