【问题标题】:PerformSegue does not perform correctlyPerformSegue 无法正确执行
【发布时间】:2013-08-30 01:48:34
【问题描述】:

如您所见,我正在尝试将 performSegue 从 Photo Action View Controller 更改为 Setting View Controller (UITableViewController)。

所以我直接从PhotoActionViewController 执行(不使用按钮等),因为我想在用户点击显示AlertView 的一个选项时执行此转场。在我为SettingsViewController 设置类之前,一切都像魅力一样工作。 segue 执行但我看不到任何UITableViewCell。我怎样才能得到这份工作?

这是我的代码:

- (IBAction)imageViewTapped:(UITapGestureRecognizer *)sender
{
    BlockAlertView *alert = [BlockAlertView alertWithTitle:@"New Photo" message:@"Decide what you would like to do with this photo"];

    [alert addButtonWithTitle:@"Create New Project" block:^{
        // Pushing to New Project Settings Controller
        [self performSegueWithIdentifier:@"NPSSegue" sender:self];
    }];
    [alert addButtonWithTitle:@"Add To Existing Project" block:^{
        NSLog(@"Add to existing");
    }];

    [alert setCancelButtonWithTitle:@"Cancel" block:nil];

    [alert show];
}

我没有发布prepareForSegue,因为它目前是空的,我不知道是否应该有任何东西。

【问题讨论】:

  • 首先。不要将self 传递给performSegueWithIdentifier,只需传递nil。现在看看剩下的......
  • 你能显示SettingsViewController的代码吗?
  • 里面什么都没有!只是继承自 UITableViewController 的新类,所以类似于:numberOfSectionsInTableView: 等。
  • SettingsViewController中删除所有UITableViewController 样板代码
  • 明天会检查,因为有人拿了我的测试 iPhone

标签: ios storyboard segue uistoryboardsegue


【解决方案1】:

每当以编程方式使用 segue 时,我们需要通过一个场景将 segue 连接到另一个场景(视图控制器),因此创建一个按钮使其不可见并将其连接到目标场景,并在 uialertview 委托中设置按钮 setEnabled:true 并在设置 segue 之前标识符感谢和抱歉英语不好.......

【讨论】:

  • 谢谢你,我确信这个解决方案会起作用,但我想要的是避免创建隐形按钮。从UITableViewController 中删除所有样板代码对我来说就像一个魅力!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多