ios 继续“取消”

发布于 2024-12-28 20:53:13 字数 204 浏览 2 评论 0原文

根据 XML 返回,我不希望当前的 segue 在 UIButton 触摸上执行。

我知道我可以选择要执行segue,但是如何让segue执行呢?或者至少不执行任何可用的segues

Depending on an XML return, I don't want the current segue to perform on UIButton touch.

I know I can pick which segue I want to perform, but how to I make a segue not perform? Or at least not perform any of the available segues?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

长安忆 2025-01-04 20:53:13

如果您的部署目标是 iOS 6.0 或更高版本,您可以覆盖 -[UIViewController shouldPerformSegueWithIdentifier:sender:] 方法,如果您想执行转场,则返回 YES;如果不想执行,则返回 NO

如果您的部署目标早于 iOS 6.0,您将不会收到 shouldPerformSegueWithIdentifier:sender: 消息。因此,在故事板中,不要从按钮绘制转场。相反,从按钮的视图控制器中绘制 Segue 并为 Segue 提供一个标识符。将按钮连接到其视图控制器中的IBAction。在操作中,检查是否要执行segue。如果您想执行它,请发送给自己 performSegueWithIdentifier:sender:,将您分配给的标识符传递给在故事板中继续。

If your deployment target is iOS 6.0 or later, you can override the -[UIViewController shouldPerformSegueWithIdentifier:sender:] method to return YES if you want to perform the segue and NO if you don't.

If your deployment target is earlier than iOS 6.0, you won't receive the shouldPerformSegueWithIdentifier:sender: message. So in your storyboard, don't draw the segue from the button. Instead, draw the segue from the button's view controller and give the segue an identifier. Connect the button to an IBAction in its view controller. In the action, check whether you want to perform the segue. If you want to perform it, send yourself performSegueWithIdentifier:sender:, passing the identifier you assigned to the segue in the storyboard.

空城之時有危險 2025-01-04 20:53:13

Apple 开发者文档 具有取消在 StoryBoard 中管理的 segue 的正确方法:

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender

例如:

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
    if ([identifier isEqualToString:@"listPopover"]) {
        if (self.listPopover == nil) {
            // Allow the popover segue
            return YES;
        }
        // Cancel the popover segue
        return NO;
    }
    // Allow all other segues
    return YES;
}

Apple Developer Documentation has the correct method to cancel a segue that is managed within the StoryBoard:

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender

For example:

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
    if ([identifier isEqualToString:@"listPopover"]) {
        if (self.listPopover == nil) {
            // Allow the popover segue
            return YES;
        }
        // Cancel the popover segue
        return NO;
    }
    // Allow all other segues
    return YES;
}
牵你的手,一向走下去 2025-01-04 20:53:13

查看此线程: https://stackoverflow.com/a/42161944/4791032

您可以在 func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath)

Check out this thread: https://stackoverflow.com/a/42161944/4791032

You can just check it in func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文