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”而终止应用程序,原因:“无法在包中加载 NIB:“NSBundle(已加载)”,名称为“FourthViewController.xib”

xib 文件是 xml nib 文件,它们被编译成 nib。所以你应该加载FourthViewController.nib(或简单地删除扩展)。

于 2013-01-08T11:07:31.430 回答
0

首先从该行中删除 xib,然后检查:initWithNibName:@"FourthViewController.xib"

于 2013-01-08T11:08:24.970 回答