After iOS 14 update, PKToolPicker not showing at start

Hi

Until iOS 14 update, in my APP PKToolPicker is show at start using this code.

Code Block
 override func viewDidAppear(_ animated: Bool) {
            super.viewDidAppear(animated)
            guard
                let window = view.window,
                 let  toolPicker = PKToolPicker.shared(for: window) else { return }
            toolPicker.setVisible(true, forFirstResponder: canvasView)
            toolPicker.addObserver(canvasView)
            canvasView.becomeFirstResponder()
        }


 After iOS 14 update the toolPicker is not showing, the only way to make it “shows” is add an “alert” like this, just after" canvasView.becomeFirstResponder()” in the previous code.

Code Block
       let alerta=UIAlertController(title: “Info example text", message:”Message info example text", preferredStyle:.alert)
        let accion=UIAlertAction(title: "Aceptar", style:.default, handler:nil)
              alerta.addAction(accion)
              present(alerta, animated:true, completion:nil)


This is not a “great solution”. What is the best way to make the
PKToolPicker at start, just like worked before iOS 14 update.

I also try to use " let  toolPicker = PKToolPicker.init()” but it only works in simulator not in real device.

Thanks in advance for any idea.
    
I have the same problem as u. I have a dirty workaround that at least works meanwhile we find the real solution or issue

canvasView.becomeFirstResponder()
canvasView.resignFirstResponder()
canvasView.becomeFirstResponder()

Regards,
Alex.
This is one of the ways to solve it.
We solved it in a week session called Saturday Night Coder.

Change Development Info
Maybe we set the setting iOS 14.0. Please change it into iOS 13.0.
And write a code

import UIKit
// Pencilkit
import PencilKit

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
     
    let canvas = PKCanvasView(frame: view.frame)
    view.addSubview(canvas)
    canvas.tool = PKInkingTool(.pen, color: .black, width: 30)
     
    // 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()
      }
       
    }
     
  }

  override func viewDidAppear(_ animated: Bool) {
      super.viewDidAppear(animated)
      let canvasView = PKCanvasView(frame: view.frame)
      view.addSubview(canvasView)
      guard
      let window = view.window,
      let toolPicker = PKToolPicker.shared(for: window) else { return }
      toolPicker.setVisible(true, forFirstResponder: canvasView)
      toolPicker.addObserver(canvasView)
      canvasView.becomeFirstResponder()
    }

   
}

After iOS 14 update, PKToolPicker not showing at start
 
 
Q