0

ビューコントローラーの切り替えで問題が発生しています。

私の md360AppDelegate.h ヘッダーは次のようになります

#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 をクリックすると、次のメッセージが表示されてアプリケーションがクラッシュします。

キャッチされていない例外 'NSInternalInconsistencyException' が原因でアプリを終了しています。

問題は何ですか?

4

2 に答える 2

1

スペル ミスでない限り (pipeViewDisease である必要があります)、このエラーは通常、xCode 環境外でファイルの名前が変更されたときに発生します。

これを修正するには:

  • 問題のファイルをプロジェクトから削除します
  • ファイルをプロジェクトに再インポートします。
于 2013-02-28T13:23:03.323 に答える
1

Probably just a misspelled NIB name:

initWithNibName:@"pipeViewDiease"

should be:

initWithNibName:@"pipeViewDisease"
                            ^
于 2013-02-28T13:22:41.947 に答える