gpt4 book ai didi

ios - 自定义栏按钮项目不执行 segue

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

我有一个在 viewDidLoad 中定义的右栏按钮项目:

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.

UIButton *helpButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:helpButton ];

}

我已经链接了栏按钮项目并使用标识符执行了segue,但它没有推送 View 。为什么会这样?

- (IBAction)btnShowHelp:(id)sender {

[self performSegueWithIdentifier:@"showHelp" sender:self];
}

最佳答案

删除按钮和- (IBAction)btnShowHelp:(id)sender 之间的链接,将方法更改为- (void)btnShowHelp(id)sender,然后像这样更改 viewDidLoad 中的代码:

    UIButton *helpButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[helpButton addTarget:self action:@selector(btnShowHelp:) forControlEvents:UIControlEventTouchUpInside];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:helpButton ];

关于ios - 自定义栏按钮项目不执行 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42312172/

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