2013-04-10 90 views
0

早上好! 我是很新的iPhone/iPad的編程 我的應用程序嘗試了登錄後更改意見登錄後更改視圖時崩潰的應用程序

-(void)checkLogin { 
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"LoginData" ofType:@"txt"]; 
    NSString *myText = [NSString stringWithContentsOfFile:filePath]; 
    //Parse lines into an NSArray; 
    NSArray *results= [myText componentsSeparatedByString:@"\n"];// Assumes Mac line end return 

    if([txtUsername.text isEqualToString: [results objectAtIndex:0]]&& [txtPassword.text isEqualToString: [results objectAtIndex:1]]) 
    { 
     Clients * clients = [[Clients alloc] initWithNibName:@"clients" bundle:nil]; 
     [self presentModalViewController:clients animated:YES];  
    } 

    else 
    { 
     UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Login" 
                 message:@"Wrong credentials" 
                 delegate:nil 
               cancelButtonTitle:@"Close" 
               otherButtonTitles:nil]; 
      [alert show]; 
    }  
} 
@end 

應用程序是在該行

[self presentModalViewController:clients animated:YES]; 

崩潰後崩潰(信號SIGABRT)謝謝非常!

+1

這是怎麼回事;客戶*客戶= [[關於我們分配] ...?你正在聲明一個客戶端,但分配一個AboutUs :) – Bartu 2013-04-10 18:50:04

+0

是的,這是錯誤的地方,也許你應該發佈你的「AboutUs」初始化事件。 – Akku 2013-04-10 18:52:41

+0

我正在嘗試與客戶端分配的代碼,我編輯了這個問題 – janeloulou 2013-04-10 18:54:43

回答

0
Clients * clients = [[AboutUs alloc] initWithNibName:@"clients" bundle:nil]; 
[self presentModalViewController:clients animated:YES]; 

我認爲第一行是您的應用卡住的地方。把它變成:

客戶端*客戶端= [[客戶端分配] initWithNibName:@「clients」bundle:nil]; [self presentModalViewController:clients animated:YES];

此代碼應該可以正常工作,但是在您的問題中,您在代碼中放置了某個aboutUs

我不知道你想從你問這個做什麼,但如果你希望把這個AboutUs控制器您Clients控制器裏面,你應該使用類似:

Clients *clients = [[Clients alloc] initWithRootViewController:aboutUs]; 

希望這有助於你

+0

謝謝!關於我們是一個錯誤。我編輯了我的代碼,但仍然得到異常。我一直在這花費超過幾個小時! – janeloulou 2013-04-10 19:23:57

+0

我看到你編輯的問題,試試這個:[self presentController:clients animated:YES completion:nil];這總是對我有用。請記住,當您在客戶端中分類了AboutUs時,僅將客戶端放在此代碼行中。 – 2013-04-10 20:07:22

0

您是否嘗試過做這樣的:

Clients *myClients = [[Clients alloc] init]; 
[self presentViewController:clients animated:YES completion:^(void) { 

}]; 

應該正常工作。如果它仍然崩潰,那麼Clients類中的某些內容出錯了。

相關問題