PencilKit无法同时满足约束条件

问题描述 投票:0回答:1

我正在尝试实现出现在屏幕底部的铅笔工具包工具套件(一支铅笔,橡皮擦等)。但是,运行此行代码后:

guard let window = view.window, let toolPicker = PKToolPicker.shared(for: window)
else {return}

我在日志中收到以下错误,并且没有显示工具选择器:

    PDF Reader[926:85385] [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:0x60000191d450 UIView:0x7fdfb7376ff0.height == 75   (active)>",
    "<NSLayoutConstraint:0x60000191d4a0 V:|-(0)-[UIView:0x7fdfb7376ff0]   (active, names: '|':PKPaletteContainerView:0x7fdfb737b7e0 )>",
    "<NSLayoutConstraint:0x60000191dae0 V:|-(0)-[PKPaletteContainerView:0x7fdfb737b7e0]   (active, names: '|':UIView:0x7fdfb46181d0 )>",
    "<NSLayoutConstraint:0x60000191dc70 PKPaletteContainerView:0x7fdfb737b7e0.bottom == UIView:0x7fdfb46181d0.bottom   (active)>",
    "<NSLayoutConstraint:0x600001901ea0 V:|-(0)-[UIView:0x7fdfb46181d0]   (active, names: '|':PKPaletteView:0x7fdfb462d3e0 )>",
    "<NSLayoutConstraint:0x600001901ef0 UIView:0x7fdfb46181d0.bottom == PKPaletteView:0x7fdfb462d3e0.bottom   (active)>",
    "<NSLayoutConstraint:0x6000019fcf00 PKPaletteView:0x7fdfb462d3e0.height == 122   (active)>",
    "<NSLayoutConstraint:0x60000191d720 UIView:0x7fdfb7376ff0.bottom == PKPaletteContainerView:0x7fdfb737b7e0.bottom   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60000191d450 UIView:0x7fdfb7376ff0.height == 75   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

我不太确定如何弄乱PKPalette的约束或下面有哪些约束冲突。我还尝试了禁用translatesAutoResizingMaskIntoConstraints,但由于我的应用程序的其他部分依赖于它,所以它不起作用。感谢您的任何帮助,谢谢!

ios swift xcode pencilkit
1个回答
0
投票

不是因为限制;您需要致电以下行:

toolPicker.setVisible(true, forFirstResponder: canvasView)
canvasView.becomeFirstResponder()

您可以在这里找到更多信息:

https://developer.apple.com/documentation/pencilkit/drawing_with_pencilkithttps://developer.apple.com/videos/play/wwdc2019/221/

© www.soinside.com 2019 - 2024. All rights reserved.