小编Mar*_*ijn的帖子

Popoverpresentation viewcontroller 和约束​​问题

我尝试调用 popoverpresentation 视图控制器以在 ipad 上共享图像,但是当发生这种情况时,我收到错误“无法满足约束”。

事情是为了解决这个问题,我删除了所有约束,这样我就可以重新开始,但即使没有约束,我也会遇到同样的错误。

所以我的问题是。这是一个错误还是我必须为 popoverpresentation 视图控制器设置约束。

这是我的代码:

print("Current device is an iPad")
print("Current device is \(UIDevice.current)")

if let imageCheck = image {
    let imageToShare = [imageCheck]
    let activityVC = UIActivityViewController(activityItems: imageToShare, applicationActivities: nil)

    activityVC.popoverPresentationController?.sourceView = super.view
    self.present(activityVC, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

和控制台中的错误:

Current device is an iPad
Current device is <UIDevice: 0x280c8d260>
2019-12-26 20:31:22.662290+0100 Petfie[2184:756367] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't …
Run Code Online (Sandbox Code Playgroud)

xcode constraints ios swift uipopoverpresentationcontroller

3
推荐指数
1
解决办法
539
查看次数