简体   繁体   English

不能执行Segue iOS

[英]Segue not being performed ios

I've got an iOS app that allows a user to connect to our server and perform a couple tasks. 我有一个iOS应用程序,允许用户连接到我们的服务器并执行一些任务。 It works great until I decided to throw an error in and make it go back to the previous view controller. 在我决定抛出错误并将其返回到先前的视图控制器之前,它一直很好用。 I created a segue with the Identifier of "segShowError" that is supposed to be executed and send the user back to the parent screen. 我使用“ segShowError”的标识符创建了一个序列,该序列应该被执行并将用户发送回父屏幕。 Currently the segue is a Modal, as is the one that goes from the first controller to the second one. 当前,segue是Modal,从第一个控制器到第二个控制器也是如此。 The odd part is I was experiencing this same difficulty earlier when I was using a push segue and I fixed it by using a Modal instead. 奇怪的是,当我使用推杆功能时,我也遇到了同样的困难,而我改用Modal来解决它。 Here is the code that "should" be performing the segue. 这是“应该”执行segue的代码。

NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if(error != nil)
{
    NSLog(@"Error was %@",error);
    return;
}
else if([data length] <= 0)
{
    NSLog(@"No data received, going back");
    [self performSegueWithIdentifier:@"segShowError" sender:self];
}

And then I have a prepareForSegue method, it will determine what error message to send back to the parent, but right now just logs a message. 然后,我有一个prepareForSegue方法,它将确定要发送回父级的错误消息,但现在仅记录一条消息。

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    NSLog(@"Preparing for segue");
}

My output 我的输出

2012-03-21 13:14:39.148 SSPColorImprov[17401:f803] No data received, going back 2012-03-21 13:14:39.148 SSPColorImprov [17401:f803]未收到数据,请返回

2012-03-21 13:14:39.149 SSPColorImprov[17401:f803] Preparing for segue 2012-03-21 13:14:39.149 SSPColorImprov [17401:f803]准备segue

I would think that those two messages would indicate that the segue is being performed, but I could be wrong. 我认为这两个消息将表明正在执行segue,但是我可能是错的。

There are no errors logged, no warnings in the project, and no exceptions thrown. 没有记录错误,在项目中没有警告,也没有抛出异常。 Any ideas what might be causing the problem? 有什么想法可能导致问题吗?

To dismiss a view that is presented modally, you need to dismiss it by calling - dismissViewControllerAnimated:completion: rather than using segues. 要关闭以模态显示的视图,您需要通过调用- dismissViewControllerAnimated:completion:来关闭它,而不是使用segues。 eg 例如

 // used to be dismissModalViewControllerAnimated: but deprecated in iOS 5 [self dismissViewControllerAnimated:YES completion:nil]; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM