0

ログイン画面を使用してサーバーと通信するときにアプリを作成しようとしています。
サーバーに接続すると、ログインが正しい場合は値 true が返され、正しくない場合は false が返されます。
次に、ログインのみが正しい場合に、アプリを新しい UIViewController に切り替えるようにします (ログイン ボタンを押した後)。
そのために、サーバーが返す値を文字列に格納し、それを別の値と比較して、UIViewController スイッチを実装します。
アプリを実行した後、エラーが発生します

:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 

Could not load NIB in bundle: 'NSBundle </Users/dimitriskoumouras/Library/Application Support/iPhone 

Simulator/6.0/Applications/9E756F03-38C1-453C-A26E-497AA7DDAECA/Administrator.app> (loaded)' 

with name 'FourthViewController.xib''!! 

いくつかのコードを投稿する:

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data {
    NSLog(@"EWYFPicOneViewController - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data {");
    string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
    NSLog(@" data == %@",string);

    NSString *compare = [NSString stringWithFormat:@"true"];

    if ( [compare isEqualToString:string])  {
        UIViewController* FourthViewController = [[UIViewController alloc] initWithNibName:@"FourthViewController.xib" bundle:[NSBundle mainBundle]];
        [self.view addSubview:FourthViewController.view];
    }
    else
        NSLog(@"validation not complete");
}

何かご意見は??(私の論理全体が間違っているのではないかと思い始めました)..

前もって感謝します!!

4

3 に答える 3

1

解析後にこれを試してください...

 if ( [compare isEqualToString:string])  {

UIViewController* FourthViewController = [[UIViewController alloc] initWithNibName:@"FourthViewController" bundle:[NSBundle mainBundle]];
 [self.navigationController pushViewController:FourthViewController animated:YES];

}

これも使って……。

  UIViewController* FourthViewController = [[UIViewController alloc] initWithNibName:@"FourthViewController" bundle:[NSBundle mainBundle]];
  [self.view addSubview:FourthViewController.view];
于 2013-01-08T11:07:21.727 に答える
1

アプリを実行した後、エラーが発生しました: キャッチされていない例外 'NSInternalInconsistencyException' が原因でアプリを終了しています。

xib ファイルは xml nib ファイルであり、nib にコンパイルされます。したがって、ロードする必要がありますFourthViewController.nib(または単に拡張機能を削除する必要があります)。

于 2013-01-08T11:07:31.430 に答える
0

最初にこの行から xib を削除してから、次を確認します: initWithNibName:@"FourthViewController.xib"

于 2013-01-08T11:08:24.970 に答える