gpt4 book ai didi

ios - 如何在导航 Controller 模式对话框 View 中触发后退按钮

转载 作者:行者123 更新时间:2023-11-29 03:17:21 25 4
gpt4 key购买 nike

第一个 View 有一个组合按钮,调用组合 View 作为模态对话框。我在第二个 View 中添加了一个取消按钮。在哪里添加取消按钮的操作?

ComposeTweetVC* composeViewController = [[ComposeTweetVC alloc] initWithNibName:@"ComposeTweetVC" bundle:[NSBundle mainBundle]];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:composeViewController];

UIBarButtonItem *newBackButton =
[[UIBarButtonItem alloc] initWithTitle:@"Cancel"
style:UIBarButtonItemStyleBordered
target:nil
action:@selector(backPressed:)];

composeViewController.navigationItem.leftBarButtonItem = newBackButton;

[self presentViewController:nvc animated:YES completion:nil];

我在哪里添加 backPressed 方法?如果我添加到调用 composeviewcontroller 的 viewcontroller,它永远不会被调用。

最佳答案

您可以将它添加到任何您想要的地方。

你的问题是:

target:nil

您实际上是在调用 [nil backPressed:],这是一个 NOOP。

尝试将 nil 更改为 selfcomposeViewController,或您希望在按下按钮时收到通知的任何对象。

关于ios - 如何在导航 Controller 模式对话框 View 中触发后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21544416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com