【问题标题】:Not able to perform segue back using storyboard无法使用情节提要执行转场
【发布时间】:2014-04-09 11:36:22
【问题描述】:

我已经开始使用 segue 在视图控制器之间执行导航。这就是我执行从 EPSearchResultController 到目标视图控制器的推送 segue 的方式。

   //.h file
@property (strong, nonatomic) EPSearchResultController *obj_EPFirstViewController;

    //.m File

    - (IBAction)submitEPSearchQuery:(id)sender {
    [self performSegueWithIdentifier:@"searchResultSegue" sender:sender];
}


    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"searchResultSegue"])
    {
        self.obj_EPFirstViewController = (EPSearchResultController*)[segue destinationViewController];
        self.obj_EPFirstViewController.searchAgainDelegate = self;
        NSDictionary* resultDict= [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"SearchResult" ofType:@"plist"]];
        self.obj_EPFirstViewController.searchResultArray = [resultDict objectForKey:@"Result"];
    }
}

问题:

当我从目的地移回 EPSearchResultController 时,它显示黑屏。我正在使用

#pragma mark - Search Again Delegate

-(void)moveBack{

    [self.navigationController popViewControllerAnimated:YES];
}

任何人都知道为什么它显示黑屏。

【问题讨论】:

  • searchResultsSegue 是什么类型的segue?是推式转场还是模态?
  • 正如我所提到的,它是一个 PUSH Segue。
  • 发现问题看我的回答:-)

标签: ios objective-c ios7 segue


【解决方案1】:

1) 在 Storyboard 中检查 segue 的呈现风格。可以是:

  • 推送
  • 模态
  • 自定义

2) 使用正确的关闭方法。 如果推送,请使用[self.navigationController popViewControllerAnimated:YES]
如果是模态,[self dismissViewControllerAnimated:YES completion:];

【讨论】:

  • 为什么不使用默认的后退导航按钮?
  • 发现问题看我的回答:-)
【解决方案2】:

感谢您的支持...从您的回答中,我了解到 segue 形成存在一些问题。我发现我从 EPSearchResultController 上的按钮转到目标视图控制器。但它应该是从 EPSearchResultController 到目标视图控制器。 :-)

【讨论】:

  • 啊!是的,如果您使用代码performSegueWithIdentifier 运行segue,那么它需要从VC 到VC。您可以删除您的 IBAction 代码,然后从按钮设置 segue。它会做同样的事情。
猜你喜欢
  • 2013-09-27
  • 1970-01-01
  • 2012-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多