gpt4 book ai didi

objective-c - 向 NavigationViewController 的后退按钮添加一些操作

转载 作者:行者123 更新时间:2023-11-28 22:49:56 26 4
gpt4 key购买 nike

我想强制我的 navigationViewController 的后退按钮调用 dissmissmodalViewController 以防止用户快速点击后退按钮并且应用程序向已释放的实例发送消息...我该如何解决?谢谢

最佳答案

您的问题感觉有点奇怪,因为后退按钮通常会执行以下操作:

[self.navigationController popViewControllerAnimated:YES];

我不确定这对任何模态视图 Controller 有何影响。如果你真的需要改变它的功能,那么你基本上会隐藏内置的后退按钮并将它替换为你自己的自定义一种,如下所示:(把它放在 viewDidLoad 中)

[self.navigationItem setHidesBackButton:YES]; //hide the built in button

//create your new button
UIBarButtonItem *b = [[UIBarButtonItem alloc]initWithTitle:@"new-back-button" style:UIBarButtonItemStyleDone target:self action:@selector(customBackButton:)];

//set the new button
self.navigationItem.leftBarButtonItem = b;

然后设置你的新方法来处理按钮推送

- (IBAction)customBackButton:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}

祝你的项目好运。

关于objective-c - 向 NavigationViewController 的后退按钮添加一些操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12251581/

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