英文:
CarPlay setRootTemplate is deprecated
问题
Xcode告诉我,'setRootTemplate(_:animated:)'
在iOS 14.0中已被弃用。新的方法是什么?
英文:
So now I am using
let listTemplate = CPListTemplate(title: "name", sections: sections)
interfaceController?.setRootTemplate(listTemplate, animated: true)
to set the template but Xcode tells me this: 'setRootTemplate(_:animated:)' was deprecated in iOS 14.0
What is the new way to do this?
答案1
得分: 2
Sure, here is the translated content:
使用 The New One With Completion In Docs
interfaceController?.setRootTemplate(listTemplate, animated: true, completion: nil)
您也可以使用异步版本
Task {
do {
let listTemplate = CPListTemplate(title: "name", sections: sections)
try await interfaceController.setRootTemplate(listTemplate, animated: true)
}
catch {
print(error)
}
}
英文:
Use The New One With Completion In Docs
interfaceController?.setRootTemplate(listTemplate, animated: true,completion:nil)
You can also use the async version
Task {
do {
let listTemplate = CPListTemplate(title: "name", sections: sections)
try await interfaceController.setRootTemplate(listTemplate, animated: true)
}
catch {
print(error)
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论