【问题标题】:dismissModalViewControllerAnimated not working as expecteddismissModalViewControllerAnimated 没有按预期工作
【发布时间】:2012-03-02 11:10:32
【问题描述】:

我试图关闭我的视图,但由于某种原因调用 [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

【问题讨论】:

  • 你确定它被调用了吗??你的解雇代码?
  • 是的,我通过了它
  • 你用什么方法调用dismissModalViewControllerAnimated?请显示更多上下文。

标签: iphone ios5


【解决方案1】:

尝试使用 dismissViewControllerAnimated:completion: 代替。

【讨论】:

    猜你喜欢
    • 2021-10-19
    • 2020-03-18
    • 2012-06-14
    • 2014-11-15
    • 1970-01-01
    • 2012-07-02
    • 2011-09-07
    • 2013-03-03
    • 2015-05-18
    相关资源
    最近更新 更多