CarPlay InformationTemplate Custom Back Button Handle Problem

53 Views Asked by At

Our iOS project supported CarPlay and has an information template. I want to use a custom back button on the information template but the handle function is not working.

Code for creating a Back button:

   func showInformationTemplate() {

        if #available(iOS 14.0, *) {
            
            let item = CPInformationItem(title: "Hello", detail: "World!")
            
            let action = CPTextButton(title: "Action", textStyle: .normal) { button in
                debugPrint("Action button pressed")
            }
            
            let backButton = CPBarButton(title: "Back") { button in
                debugPrint("Back button pressed")
            }
            
            let template = CPInformationTemplate(title: "Info", layout: .twoColumn, items: [item], actions: [action])
            
            template.backButton = backButton
            
            carplayInterfaceController?.pushTemplate(template, animated: true)
            
        } else {
            // Fallback on earlier versions
        }
        
    }
0

There are 0 best solutions below