ios - 应该如何使用 showAlertViewForRequestOperationWithErrorOnCompletion?

标签 ios afnetworking-2

我不确定如何使用新 AFNetworking 中的 showAlertViewForRequestOperationWithErrorOnCompletion。我尝试了以下操作,但没有显示alertView。

[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id requestObject) {
    // ...
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    [UIAlertView showAlertViewForRequestOperationWithErrorOnCompletion:operation
                                                              delegate:nil];
}];

最佳答案

  1. 您确定已到达该代码行吗?
  2. 仅当操作错误非零时才会显示警报。您确定是这样吗?

更新:

好的,看起来像implementation调用此方法不会立即显示警报,而只是将其设置为当操作失败时显示警报。所以你可能必须这样做:

[UIAlertView showAlertViewForRequestOperationWithErrorOnCompletion:requestOperation
                                                              delegate:nil];

[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id requestObject) {

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

}];

关于ios - 应该如何使用 showAlertViewForRequestOperationWithErrorOnCompletion?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20505568/

相关文章:

ios - AFHTTPSessionManager 便捷方法(GET、POST、PUT 等)和后台传输

java - 将 JSON 数据从 iOS 发布到 java Web 服务

ios - 开始使用 UIDatePicker 时的 Action

c# - 从代码创建手势识别器

ios - 如何从图像创建电影*图像之间的过渡*

ios - 如何为 iPhone 6 和 6 Plus 上的应用启用原生分辨率?

ios - 具有多个快速连续请求的 AFHTTPSessionManager (AFNetworking 2.0)

ios - 使用 AFNetworking 2.0 创建自己的委托(delegate)和协议(protocol)

ios - 使用 SDWebImage 而不是 AFNetworking 进行图像加载有很大优势吗?

ios - 为什么按钮未启用?