2012-03-02 164 views
0

我想解僱我的觀點,但由於某種原因調用時[self dismissModalViewControllerAnimated:NO];什麼都沒發生。dismissModalViewControllerAnimated不按預期工作

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

+0

你確定它正在被調用嗎?你的解僱代碼? – Shubhank 2012-03-02 11:22:08

+0

是的,我穿過它 – Armand 2012-03-02 11:26:05

+0

你用什麼方法調用dismissModalViewControllerAnimated?請顯示更多的上下文。 – ader 2012-03-02 12:11:11

回答

1

嘗試使用dismissViewControllerAnimated :完成:代替。