gpt4 book ai didi

ios - 将 UIBarButtonSystemItemAdd 推送到不同的 View Controller

转载 作者:行者123 更新时间:2023-11-28 20:23:33 25 4
gpt4 key购买 nike

我正在尝试将添加按钮推送到不同的 View Controller ,但我没有使用 Storyboard。该按钮出现但在单击时不执行任何操作。这是我的代码:

-(void)pushLogin
{
[self.navigationController pushViewController:[[AddListingViewController alloc] init] animated:YES];
}

- (void)viewDidLoad
{
[super viewDidLoad];

self.navigationItem.title = @"Listings";

UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:nil
action:@selector(pushLogin)];
self.navigationItem.rightBarButtonItem = addButton;
}

有什么建议吗?

最佳答案

目标应该是viewcontroller,而不是nil

 UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self
action:@selector(pushLogin)];

关于ios - 将 UIBarButtonSystemItemAdd 推送到不同的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14988472/

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