Armand
Armand

Reputation: 10254

dismissModalViewControllerAnimated not working as expected

I am trying to dismiss my view but for some reason when calling [self dismissModalViewControllerAnimated:NO]; nothing happens.

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


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

Then in my login view controller after logging in

- (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];
        }
    }
}

I have searched every where and can't figure out why this is happening

dismissModalViewControllerAnimated not working

Upvotes: 0

Views: 1032

Answers (1)

saman01
saman01

Reputation: 1004

Try Use dismissViewControllerAnimated:completion: instead.

Upvotes: 1

Related Questions