CarPlay setRootTemplate已过时

huangapple go评论78阅读模式
英文:

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)
  }
}

huangapple
  • 本文由 发表于 2023年5月15日 05:20:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76249737.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定