gpt4 book ai didi

ios - NSInternalInconsistencyException 错误

转载 作者:行者123 更新时间:2023-11-28 22:38:48 24 4
gpt4 key购买 nike

我在 View Controller 之间切换时遇到问题。

我的 md360AppDelegate.h header 如下所示

#import <UIKit/UIKit.h>
@class md360ViewController;
@interface md360AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) md360ViewController *viewController;
@property (strong, nonatomic) UINavigationController *navigationController;
@end

我的 md360AppDelegate.m 实现如下所示。

#import "md360AppDelegate.h"
#import "md360ViewController.h"

@implementation md360AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[md360ViewController alloc] initWithNibName:@"md360ViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.window setRootViewController:self.navigationController];
[self.window makeKeyAndVisible];
return YES;
}
@end

我正在创建 UINavigationController 的实例并将其存储在此类的 navigationController 属性中。

我想在用户单击 md360ViewController 中的按钮时更改 ViewController。

我的 md360ViewController.h 看起来像这样。

@interface md360ViewController : UIViewController
@property IBOutlet UIButton *homePathwayBtn;
@property IBOutlet UIButton *homeDiseaseBtn;
@property IBOutlet UIButton *homePipelineBtn;
- (IBAction)homeButton:(id)sender;
@end

我的实现看起来像

#import "md360ViewController.h"
#import "md360AppDelegate.h"
#import "pipeViewDisease.h"
#import <QuartzCore/QuartzCore.h>

- (IBAction)homeButton:(id)sender {
UIViewController *pipeViewDisease = [[UIViewController alloc] initWithNibName:@"pipeViewDiease" bundle:nil];
[self.navigationController pushViewController:pipeViewDisease animated:YES];
}

当我点击 UIButton 时,应用程序崩溃并显示以下消息。

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'pipeViewDiease''

可能是什么问题?

最佳答案

可能只是一个拼写错误的 NIB 名称:

initWithNibName:@"pipeViewDiease"

应该是:

initWithNibName:@"pipeViewDisease"
^

关于ios - NSInternalInconsistencyException 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15136623/

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