Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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
Ios 无法使用共享工作表共享多个图像_Ios_Swift_Uiactivityviewcontroller_Visionkit - Fatal编程技术网

Ios 无法使用共享工作表共享多个图像

Ios 无法使用共享工作表共享多个图像,ios,swift,uiactivityviewcontroller,visionkit,Ios,Swift,Uiactivityviewcontroller,Visionkit,我试图保存使用vision kit扫描的多张图像,但似乎只有第一张图像使用共享表保存。我如何纠正这个问题 扫描后保存图像 for i in 0...scan.pageCount-1 { let originalImage = scan.imageOfPage(at: i) let fixedImage = originalImage.jpegData(compressionQuality: 0.7) let reloadedImage = UIImage(d

我试图保存使用vision kit扫描的多张图像,但似乎只有第一张图像使用共享表保存。我如何纠正这个问题

扫描后保存图像

for i in 0...scan.pageCount-1 {
      let originalImage = scan.imageOfPage(at: i)
      let fixedImage =  originalImage.jpegData(compressionQuality: 0.7)
      let reloadedImage = UIImage(data: fixedImage!)
      let imagetoshare = [reloadedImage!]
      
      let activityViewController = UIActivityViewController(activityItems: imagetoshare, applicationActivities: nil)
      if let popoverController = activityViewController.popoverPresentationController {
      popoverController.sourceView = self.view
      popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
      popoverController.permittedArrowDirections = []
      }
      // exclude some activity types from the list (optional)
      // present the view controller
      self.present(activityViewController, animated: true, completion: nil)
}
添加popover控制器代码是因为iPad在打开共享表时出现问题

尝试保存多个图像时出现错误代码I

2020-10-03 16:17:21.300830+0530 Scan Box[1163:132306] [ShareSheet] connection invalidated
如果您想知道ReloadeImage函数是什么:

func reloadedImage(_ originalImage: UIImage) -> UIImage {
      guard let imageData = originalImage.jpegData(compressionQuality: 1),
            let reloadedImage = UIImage(data: imageData) else {
                return originalImage
      }
      return reloadedImage
}
编辑: 我已从pageCount中删除了'-1',出现以下错误:

-[VNDocumentCameraScan imageOfPageAtIndex:]: index (2) beyond bounds (2).'
编辑2:

       var imagetoShare = [UIImage]()
                for i in 0...scan.pageCount-1 {
                    let originalImage = scan.imageOfPage(at: i)
                    let fixedImage =  originalImage.jpegData(compressionQuality: 0.7)
                    
                    let reloadedImage = UIImage(data: fixedImage!)
                    imagetoShare.append(reloadedImage!)
                  
                        
                        let activityViewController = UIActivityViewController(activityItems: imagetoShare, applicationActivities: nil)
                        if let popoverController = activityViewController.popoverPresentationController {
                        popoverController.sourceView = self.view
                          popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
                          popoverController.permittedArrowDirections = []
                            
                      }
                              
                              // exclude some activity types from the list (optional)


                              // present the view controller
                              self.present(activityViewController, animated: true, completion: nil)
                    
我甚至试过:

imagetoShare: [UIImage] = [UIImage]()
但还是没有运气

在这些更改之后,我的调试器日志显示

2020-10-06 16:02:03.813409+0530 Scan Box[1706:336940] [] [16:02:03.811] SurfacePool_DetachSurface signalled err=-16990 (kFigPhotoError_InvalidParameter) (Surface not found in pool) at /Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMedia/EmbeddedCoreMedia-2755.18.2.1.1/Sources/Photo/FigPhotoSurfacePool.c:1118
2020-10-06 16:02:06.469717+0530 Scan Box[1706:336940] [] [16:02:06.470] SurfacePool_DetachSurface signalled err=-16990 (kFigPhotoError_InvalidParameter) (Surface not found in pool) at /Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMedia/EmbeddedCoreMedia-2755.18.2.1.1/Sources/Photo/FigPhotoSurfacePool.c:1118
2020-10-06 16:02:09.287991+0530 Scan Box[1706:336940] [Presentation] Attempt to present <UIActivityViewController: 0x102055600> on <UINavigationController: 0x102018e00> (from <Scan_Box.ViewController: 0x102019400>) while a presentation is in progress.
2020-10-06 16:02:09.290234+0530 Scan Box[1706:336940] [Presentation] Attempt to present <UIActivityViewController: 0x101a0f200> on <UINavigationController: 0x102018e00> (from <Scan_Box.ViewController: 0x102019400>) while a presentation is in progress.
2020-10-06 16:02:09.292873+0530 Scan Box[1706:337619] [ShareSheet] connection invalidated
2020-10-06 16:02:09.294701+0530 Scan Box[1706:338340] [ShareSheet] connection invalidated
2020-10-06 16:02:15.780167+0530 Scan Box[1706:338348] [ShareSheet] connection invalidated
2020-10-06 16:02:03.813409+0530扫描框[1706:336940][[16:02:03.811]表面pool_DetachSurface信号错误=-16990(kFigPhotoError_InvalidParameter)(在池中找不到表面)位于/Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMedia/EmbeddedCoreMedia/EmbeddedCoreMedia-2755.18.2.1.1/Sources/Photo/FigPhotoSurfacePool.c:1118
2020-10-06 16:02:06.469717+0530扫描框[1706:336940][[16:02:06.470]表面pool_DetachSurface Signaled err=-16990(kFigPhotoError_InvalidParameter)(在池中找不到表面)位于/Library/Caches/com.apple.xbs/Sources/EmbeddedCoreMedia/EmbeddedCoreMedia-2755.18.2.1/Sources/Photo/FigPhotoSurfacePool.c:1118
2020-10-06 16:02:09.287991+0530扫描框[1706:336940][演示文稿]在演示文稿正在进行时尝试在(从)上演示。
2020-10-06 16:02:09.290234+0530扫描框[1706:336940][演示文稿]在演示文稿正在进行时尝试在(从)上演示。
2020-10-06 16:02:09.292873+0530扫描框[1706:337619][ShareSheet]连接无效
2020-10-06 16:02:09.294701+0530扫描框[1706:338340][ShareSheet]连接无效
2020-10-06 16:02:15.780167+0530扫描框[1706:338348][ShareSheet]连接无效
请帮我解决这个问题。
提前谢谢

您创建了一组UIActivityViewController,以从代码中显示在循环中,因此只显示其中的第一个,因为将跳过下一个。 您应该首先创建要共享的图像数组,然后使用此数组显示控制器

// Prepare array of images to share
var images = [UIImage]()
for i in 0...scan.pageCount-1 {
    ...
    images.append(reloadedImage!)
}
// Create and present single activity controller
let activityViewController = UIActivityViewController(activityItems: images, applicationActivities: nil)
...
self.present(activityViewController, animated: true, completion: nil)

不,它仍然不起作用:(检查我对调试器日志的编辑。我也有同样的问题,请给出更多可能有用的建议。@Manav103只需移出创建并从循环中显示UIActivityViewController。非常感谢@iUrii这真的帮了我很大的忙。这么简单的修复!