我有一个用例,每当 API 调用中发生诸如互联网丢失或未知错误之类的一般错误时,需要显示带有重试按钮的错误 UI。当用户按下重试之前失败的 API 时,应该调用并恢复用户流程。
迁移协程方法前的API接口:
interface TodoService {
@POST("todo/create")
fun createTodo(@Body request: TodoRequest): Call<TodoResponse>
}
Run Code Online (Sandbox Code Playgroud)
API客户端:
fun <T> fetch(call: Call<T>, completion: (result: NetworkBoundResource<T>) -> Unit) {
call.enqueue(object : Callback<T> {
override fun onFailure(call: Call<T>, t: Throwable) {
// I have the mechanism save call object and completion and show error UI
// when user press retry fetch(call.clone(), completion
}
override fun onResponse(call: Call<T>, response: Response<T>) {
}
})
}
Run Code Online (Sandbox Code Playgroud)
在将改造接口迁移到协程挂起方法之前,这不是问题。因为我可以克隆改造调用对象(call.clone())并重试 API 调用,如代码注释中所述。
迁移协程方法后的API接口:
interface TodoService { …Run Code Online (Sandbox Code Playgroud) 嗨,我正在使用Xamarin.Forms基于PCL的解决方案开发应用程序.对于我的应用程序,我需要Listview ViewCell Contextaction.我引用了这个文档来添加contextActions.当我在android中运行它时,图标正在显示.但在iOS中它不起作用.
Xaml代码
<ViewCell.ContextActions>
<MenuItem Text="Edit" x:Name="MenuEdit" />
<MenuItem Clicked="OnDeleteMenu" Icon="dustbin.png" Text="Delete" IsDestructive="true"
CommandParameter="{Binding .}" />
</ViewCell.ContextActions>
Run Code Online (Sandbox Code Playgroud)
请任何人提供解决方案或相关来源.
我想使用ARKit和RealityKit检测 2D 图像。我不想使用 SceneKit,因为很多实现都基于 RealityKit。我在 RealityKit 上找不到任何检测图像的示例。我参考了苹果的https://developer.apple.com/documentation/arkit/detecting_images_in_an_ar_experience示例代码。它使用 Scenekit 和ARSCNViewDelegate
let arConfiguration = ARWorldTrackingConfiguration()
arConfiguration.planeDetection = [.vertical, .horizontal]
arConfiguration.isLightEstimationEnabled = true
arConfiguration.environmentTexturing = .automatic
if let referenceImages = ARReferenceImage.referenceImages(inGroupNamed: "sanitzer", bundle: nil) {
arConfiguration.maximumNumberOfTrackedImages = 1
arConfiguration.detectionImages = referenceImages
}
self.session.run(arConfiguration, options: [.resetTracking, .removeExistingAnchors])
Run Code Online (Sandbox Code Playgroud)
我已实施ARSessionDelegate但无法检测图像?
func session(_ session: ARSession, didAdd anchors: [ARAnchor]) {
//how to capture image anchor?
}
func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
//how to capture image anchor? …Run Code Online (Sandbox Code Playgroud) android ×1
arkit ×1
kotlin ×1
listview ×1
realitykit ×1
retrofit2 ×1
swift ×1
xamarin ×1
xamarin.ios ×1