environment
・MacOS: 10.15.7
・Xcode: 12.1
・iOS: 14.1
I'm trying to make a paint app But I cannot show PKToolPicker. I set my code as below.
Line 37 I get a warning here↓
'shared(for:)' was deprecated in iOS 14.0: Create individual instances instead.
So I changed it like this
But I did not succeed.
What should i do in this case?
・MacOS: 10.15.7
・Xcode: 12.1
・iOS: 14.1
I'm trying to make a paint app But I cannot show PKToolPicker. I set my code as below.
Code Block import UIKit import PencilKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. // Three Lines of Code ここに3行のコードを足す let canvas = PKCanvasView(frame: view.frame) view.addSubview(canvas) canvas.tool = PKInkingTool(.pen, color: .black, width: 30) canvas.drawingPolicy = .anyInput //PKToolPicker: ドラッグして移動できるツールパレット (ペンや色などを選択できるツール) if let window = UIApplication.shared.windows.first { if let toolPicker = PKToolPicker.shared(for: window) { toolPicker.addObserver(canvas) toolPicker.setVisible(true, forFirstResponder: canvas) canvas.becomeFirstResponder() } } } }
Line 37 I get a warning here↓
'shared(for:)' was deprecated in iOS 14.0: Create individual instances instead.
So I changed it like this
Code Block let toolPicker = PKToolPicker.init() toolPicker.addObserver(canvas) toolPicker.setVisible(true, forFirstResponder: canvas) canvas.becomeFirstResponder()
But I did not succeed.
What should i do in this case?