gpt4 book ai didi

iOS UIBarButtonItem 链接到 ViewController

转载 作者:行者123 更新时间:2023-12-01 16:29:43 25 4
gpt4 key购买 nike

我有一个关于 UIBarButtonItem 的问题链接到 Storyboard 中的另一个 ViewController。在这个顶部栏中,我在右侧有 2 个图标,使用数组执行此操作:

[self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:_meetupButton, _searchButton, nil]];

这两个按钮都在控制台中工作,但是当我想使用 meetupButton 导航时到另一个 ViewController,它不起作用。

Storyboard名称是 Main
ViewController 正确链接到 MeetupStartViewController .

当他运行以下代码时,他崩溃了。我究竟做错了什么?
- (void)toggleMeetup:(UIButton *)button {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"MeetupStartViewController"];
[self presentViewController:vc animated:YES completion:nil];
}

错误日志:

2015-09-08 15:46:46.554 APPNAME[2267:530587] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard () doesn't contain a view controller with identifier 'MeetupStartViewController''
*
First throw call stack:
(0x184e9022c 0x196b640e4 0x189eced3c 0x1000f90f0 0x1899411ec 0x1899411ec 0x18992a2c8 0x189940b88 0x189940814 0x189939d50 0x18990cf74 0x189bae124 0x18990b488 0x184e47f8c 0x184e47230 0x184e452e0 0x184d70f74 0x18e7cb6fc 0x189972d94 0x1000a2764 0x19720ea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)


MeetupStartViewController是一个 Swift 类,其他代码是 Objective-C。

最佳答案

您似乎没有为 MeetupStartViewController 设置所需的 ID。

为此,请进入 Storyboard,选择 MeetupStartViewController。
选中复选框:使用 Storyboard ID 并在 StoryboardID 框中写入“MeetupStartViewController”。这是一个视觉示例:

enter image description here

关于iOS UIBarButtonItem 链接到 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32458978/

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