Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.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/0/iphone/42.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 iPhone 7/7plus上的空快照视图_Ios_Iphone_Swift3_Ios10 - Fatal编程技术网

Ios iPhone 7/7plus上的空快照视图

Ios iPhone 7/7plus上的空快照视图,ios,iphone,swift3,ios10,Ios,Iphone,Swift3,Ios10,我这里的第一个问题:)最近我将我的Xcode更新为8,并且resizeblesnapshotView方法在一些模拟器上不能正常工作。snapshotView在所有使用iOS9/10的测试设备和iPhone6s下的模拟器上都运行良好,但在iPhone7/7p模拟器上它是空的。我认为7/7p可能需要一些权限来访问快照,但我不知道它们是什么 let cell = self.tableView.cellForRow(at: IndexPath(row: 0, section: 0)) as! Calen

我这里的第一个问题:)最近我将我的Xcode更新为8,并且
resizeblesnapshotView
方法在一些模拟器上不能正常工作。snapshotView在所有使用iOS9/10的测试设备和iPhone6s下的模拟器上都运行良好,但在iPhone7/7p模拟器上它是空的。我认为7/7p可能需要一些权限来访问快照,但我不知道它们是什么

let cell = self.tableView.cellForRow(at: IndexPath(row: 0, section: 0)) as! CalendarCell     
var topFrame = cell.frame
topFrame.origin.y = tableView.contentOffset.y
topFrame.size.height -= tableView.contentOffset.y
topSnapshotView = tableView.resizableSnapshotView(from: topFrame, afterScreenUpdates: false, withCapInsets: UIEdgeInsets.zero)

使用以下UIView扩展插件使用CoreGraphics创建快照

我可以在iPhone7模拟器上确认这一点

public extension UIView {

    public func snapshotImage() -> UIImage? {
        UIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque, 0)
        drawHierarchy(in: bounds, afterScreenUpdates: false)
        let snapshotImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return snapshotImage
    }

    public func snapshotView() -> UIView? {
        if let snapshotImage = snapshotImage() {
            return UIImageView(image: snapshotImage)
        } else {
            return nil
        }
    }
}
工作地点:

  • 8.1版(8B62)
  • 模拟器版本10.0(SimulatorApp-700.14
Swift 3

import Foundation
import UIKit

extension UIView {
    func snapshotView() -> UIView? {
        guard let image = snapshotImage() else { return nil }
        return UIImageView(image: image)
    }

    func snapshotImage() -> UIImage? {
        UIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque, contentScaleFactor)
        defer { UIGraphicsEndImageContext() }

        drawHierarchy(in: bounds, afterScreenUpdates: false)

        return UIGraphicsGetImageFromCurrentImageContext()
    }
}

我也经历了同样的,很高兴听到它只发生在模拟器上。完全相同的问题,但是我没有在真实的设备上测试过。不幸的是,我没有真实的设备,我不确定这是否发生在真实的设备上。Xcode 8.1/iOS 10.1 Beta 1中仍然存在问题。无法在带有iOS 10的iPhone 7设备上重现它.0,所以还是希望这只是一个模拟器的问题。@LYM你有没有向苹果公司提交雷达文件?谢谢,这是可行的。但是,我的主要问题是使用
resizeblesnapshotview
这个函数。我试过用你的代码重写它,但失败了。你能告诉我如何用帧剪辑快照视图吗?这不起作用。它会产生错误对我来说,结果和以前的方法一样。在Xcode 8和iPhone 7/7+模拟器上试用过。有人知道为什么会发生这种情况吗?是的。在我升级到Xcode 8.1后,它也不起作用。