在popViewControllerAnimated:YES之后,RequestFailed方法抛出错误

时间:2012-03-28 06:26:50

标签: iphone objective-c ios uinavigationcontroller uialertview

我使用以下代码处理失败的请求。

- (void)requestFailed:(ASIHTTPRequest *)request {
    [self.alertView dismissWithClickedButtonIndex:0 animated:YES];

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Request failed." message:requestFailMessage delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [self.navigationController popViewControllerAnimated:YES];
}

要模拟,我打开“飞行模式”。我尝试了请求,但它失败了。按下“确定”按钮后,我遇到了这个错误:

2012-03-28 02:23:56.048 Obfuscated[40835:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

基本上,我只希望navigationController在请求失败时返回上一个视图控制器。但是,这似乎不起作用。

我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:1)

我认为您在警报代码下方使用popViewControllerAnimated两次,在警告方法中委托一次。

你的导航堆栈没有弹出视图,所以它会给你这个问题。

这样做

- (void)requestFailed:(ASIHTTPRequest *)request {


    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Request failed." message:requestFailMessage delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];

}


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
 [self.navigationController popViewControllerAnimated:YES];
}