【问题标题】:Segues not working (Table view/navigation controller/tab controller)Segues 不起作用(表格视图/导航控制器/选项卡控制器)
【发布时间】:2014-09-14 06:41:10
【问题描述】:

我正在编写一个使用 Parse 服务的 iOS 应用程序。当我点击一个单元格时,它并没有像我预期的那样继续。看来我的“prepareForSegue”方法没有被调用。我使用断点来确定这一点,并且 NSLog 从不输出任何内容。这是我的方法:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    NSLog(segue.identifier);
    if ([segue.identifier isEqualToString:@"showObjectDetails"]) {
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        //OfferDetailViewController *destViewController = segue.destinationViewController;
        PFObject *object = [self.objects objectAtIndex:indexPath.row];
        [segue.destinationViewController setObject:object];
    }

}

如果重要的话,segue 名称是“showObjectDetails”,它来自列表视图。我使用了 Push selection segue。我已确保在 Interface Builder 中正确设置了自定义类。我正在使用一个 Tab Bar 控制器,它引用一个 NavigationController,然后显示 tableview。

【问题讨论】:

  • 你是如何在 Storyboard 中连接你的 segue 的?

标签: ios objective-c iphone parse-platform


【解决方案1】:

确保已在 Storyboard 中设置了 Segue Identifier,如下所示。

【讨论】:

  • 我的界面看起来略有不同(它没有 Destination 选项),但我确实将样式设置为 Push,并且标识符也设置正确。
  • 试试:[self performSegueWithIdentifier:@"showObjectDetails" sender:sender];
  • 结合这个委托方法:(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-20
  • 1970-01-01
  • 2014-12-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多