Swift - iOS15.4 上的 UIActivityController 约束错误
我试图在我的应用程序中显示 UIActivityViewController
。它在 iPhone 上运行良好,但我遇到了一些限制问题:
2022-03-17 20:49:29.744955+0100 Instagrid[50308:1307722] [LayoutConstraints] Changing the translatesAutoresizingMaskIntoConstraints property of a UICollectionReusableView that is managed by a UICollectionView is not supported, and will result in incorrect self-sizing. View: <_UIActivityContentFooterView: 0x1206246f0; baseClass = UICollectionReusableView; frame = (20 506; 374 52); layer = <CALayer: 0x600001e7a400>>
2022-03-17 20:49:29.748855+0100 Instagrid[50308:1307722] [default] -imageForImageDescriptor: can do IO please adopt -imageForDescriptor: for IO free drawing or -prepareImageForDescriptor: if IO is allowed. (This will become a fault soon.)
2022-03-17 20:49:29.763300+0100 Instagrid[50308:1307722] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x600003d48280 _UIActivityActionCellTitleLabel:0x12062edd0.height >= 22 (active)>",
"<NSLayoutConstraint:0x600003d0b0c0 UIView:0x12062def0.height >= _UIActivityActionCellTitleLabel:0x12062edd0.height + 30 (active)>",
"<NSLayoutConstraint:0x600003d39540 'UIView-Encapsulated-Layout-Height' UIView:0x12062def0.height == 30 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600003d48280 _UIActivityActionCellTitleLabel:0x12062edd0.height >= 22 (active)>
奇怪的是,这个问题仅出现在 iOS 15 上。当我在 iOS 14 和 iOS 13 上尝试我的代码时,我没有收到此错误。
有人有任何提示/操作来解决这个问题吗?
编辑1 - 触发 UIActivityViewController 的代码
let imageToShare = pictureView.renderAsUIImage()
let sharingObject = [imageToShare]
let activityViewController = UIActivityViewController(activityItems: sharingObject, applicationActivities: nil)
present(activityViewController, animated: true)
func renderAsUIImage() -> UIImage {
let renderer = UIGraphicsImageRenderer(size: self.bounds.size)
return renderer.image { context in
self.drawHierarchy(in: self.bounds, afterScreenUpdates: true)
}
}
I'm trying to show a UIActivityViewController
in my application. It works well on the iPhone but I have a couple of issues with constraints:
2022-03-17 20:49:29.744955+0100 Instagrid[50308:1307722] [LayoutConstraints] Changing the translatesAutoresizingMaskIntoConstraints property of a UICollectionReusableView that is managed by a UICollectionView is not supported, and will result in incorrect self-sizing. View: <_UIActivityContentFooterView: 0x1206246f0; baseClass = UICollectionReusableView; frame = (20 506; 374 52); layer = <CALayer: 0x600001e7a400>>
2022-03-17 20:49:29.748855+0100 Instagrid[50308:1307722] [default] -imageForImageDescriptor: can do IO please adopt -imageForDescriptor: for IO free drawing or -prepareImageForDescriptor: if IO is allowed. (This will become a fault soon.)
2022-03-17 20:49:29.763300+0100 Instagrid[50308:1307722] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x600003d48280 _UIActivityActionCellTitleLabel:0x12062edd0.height >= 22 (active)>",
"<NSLayoutConstraint:0x600003d0b0c0 UIView:0x12062def0.height >= _UIActivityActionCellTitleLabel:0x12062edd0.height + 30 (active)>",
"<NSLayoutConstraint:0x600003d39540 'UIView-Encapsulated-Layout-Height' UIView:0x12062def0.height == 30 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600003d48280 _UIActivityActionCellTitleLabel:0x12062edd0.height >= 22 (active)>
Weirdly, this issue appears only on iOS 15. When I try my code on iOS 14 and iOS 13, I don't receive this error.
Does anyone have any tips/actions to solve this issue?
EDIT 1 - Code that trigger the UIActivityViewController
let imageToShare = pictureView.renderAsUIImage()
let sharingObject = [imageToShare]
let activityViewController = UIActivityViewController(activityItems: sharingObject, applicationActivities: nil)
present(activityViewController, animated: true)
func renderAsUIImage() -> UIImage {
let renderer = UIGraphicsImageRenderer(size: self.bounds.size)
return renderer.image { context in
self.drawHierarchy(in: self.bounds, afterScreenUpdates: true)
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论