弹窗提示:
照片或视频不可用
此APP正在不受支持的配置下使用“照片”选择器
英文为:
Photo or Video Unavailable
This app is using the Photos picker in an unsupported configuration.
经过翻官方文档,在这里找到了答案:
https://developer.apple.com/documentation/photokit/phpickerviewcontroller
(进入页面直接搜“17”定位)
大致意思是你让PHPickerViewController的view由于各种原因“不可见”了。这种不可见并非我们通俗理解的不可见。苹果文档中举例说明了,比如给view设置了非100%的不透明度,或者其他东西盖住它了,它就会忽略触摸交互。
看了下app,我是给全局加了水印View,为了能保证水印View能永远在所有页面的最上层,将其zPosition为Float最大值)
watermarkView.layer.zPosition = .greatestFiniteMagnitude
所以在相册弹出后,水印View在相册View之上,即使水印为全透明且透传所有的点击事件,但在iOS17上苹果仍旧给拦截住了。
最终我的解决方案是把水印View从继承UIView
改为继承UIWindow
class WatermarkView: UIWindow {
static var wmView: WatermarkView?
public static func showIfNeeded(_ view: UIView? = nil, waterMarkString: String?) {
guard waterMarkString.count > 0 else { return }
guard case let window?? = UIApplication.shared.delegate?.window else { return }
wmView?.isHidden = true
let waterView = CLSWatermarkView()
waterView.frame = UIScreen.main.bounds
waterView.backgroundColor = .clear
waterView.rootViewController = UIViewController()
waterView.windowLevel = .statusBar
waterView.isHidden = false
var x: CGFloat = 0
var y: CGFloat = 0
var lineCount: Int = 0
while (true) {
let label = UILabel()
label.text = waterMarkString
label.textColor = UIColor.black
label.alpha = 0.1
label.font = UIFont.systemFont(ofSize: 14)
waterView.addSubview(label)
label.sizeToFit()
label.frame = CGRect(x: x, y: y, width: label.width, height: label.height)
label.transform = CGAffineTransform(rotationAngle: Double.pi / -12)
x += label.width + 100
if x > UIScreen.main.bounds.width && y > UIScreen.main.bounds.height {
break
}
if x > UIScreen.main.bounds.width {
y += 70
lineCount += 1
if lineCount % 2 == 0 {
x = 0
} else {
x = 104
}
}
}
wmView = waterView
}
public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
return nil
}
}