gpt4 book ai didi

iphone - IOS Segue - 由于未捕获的异常 'NSGeneric Exception'而终止应用程序

转载 作者:行者123 更新时间:2023-12-01 18:23:43 27 4
gpt4 key购买 nike

Storyboard截图
images

在 Xcode 4.6 Storyboard 中,我有 2 个 ViewControlers,一个包含按钮,另一个是 labelView,在点击主页按钮时传递一个字符串“Home Tapped”

这是 ViewController.m 代码

#import "ViewController.h"
#import "ViewController2.h"

@interface ViewController ()

@end

@implementation ViewController

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"Home"])
{
NSString *message = @"Tapped on home";
ViewController2 *vc = [segue destinationViewController];
vc.labelString = message;
}
}

ViewController2.h
#import <UIKit/UIKit.h>

@interface ViewController2 : UITableViewController

@property(nonatomic,strong) UILabel *mylabel;
@property(nonatomic,strong) NSString *labelString;

@end

和错误
Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'Home'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
*** First throw call stack:
(0x1c91012 0x10cee7e 0x468f31 0x45ab99 0x45ac14 0x10e2705 0x162c0 0x16258 0xd7021 0xd757f 0xd66e8 0x45cef 0x45f02 0x23d4a 0x15698 0x1becdf9 0x1becad0 0x1c06bf5 0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x1beb7e3 0x1beb668 0x12ffc 0x28dd 0x2805)
libc++abi.dylib: terminate called throwing an exception
(lldb)

最佳答案

你需要让你的NavigationController Storyboard的入口点。现在是View Controller ,由指向它的箭头表示,没有来源。

关于iphone - IOS Segue - 由于未捕获的异常 'NSGeneric Exception'而终止应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15506324/

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