dismissModalViewControllerAnimated无法按预期工作

时间:2012-03-02 11:10:32

标签: iphone ios5

我试图忽略我的观点,但出于某种原因调用[self dismissModalViewControllerAnimated:NO];没有任何反应。

Options *option = [Options getInstance];
if(option.authToken != nil)
{


}
else
{
    loginViewController = [[LoginViewController alloc] init];
    [loginViewController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
    [self presentModalViewController:loginViewController animated:NO];
}

登录后登录视图控制器

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];

NSString *theXML = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>%@",[[NSString alloc] initWithBytes: [responseData mutableBytes] length:[responseData length] encoding:NSUTF8StringEncoding]];

[self handleXmlResponse:theXML];
TBXML *tbXml = [[TBXML tbxmlWithXMLString:theXML] retain];

if(tbXml)
{
    TBXMLElement *isError = [TBXML childElementNamed:@"IsError" parentElement:tbXml.rootXMLElement];
    if([[TBXML textForElement:isError] isEqualToString:@"true"])
    {
        TBXMLElement *error = [TBXML childElementNamed:@"Error" parentElement:tbXml.rootXMLElement];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login Error" 
                                                        message:[TBXML textForElement:error]
                                                       delegate:nil 
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
    else
        {
            TBXMLElement *value = [TBXML childElementNamed:@"Value" parentElement:tbXml.rootXMLElement];
            Options* option = [Options getInstance];
            option.authToken = [TBXML textForElement:value];
            NSLog(@"YES");
            [self dismissModalViewControllerAnimated:NO];
        }
    }
}

我搜遍过每一个地方,无法弄清楚为什么会发生这种情况

dismissModalViewControllerAnimated not working

1 个答案:

答案 0 :(得分:1)

尝试使用dismissViewControllerAnimated:completion:而不是。