2014-10-20 32 views
1

我創建了用戶名和密碼的登錄頁面。當我單擊登錄按鈕時,將出現錯誤的密碼消息。但它進入下一頁。任何人都可以幫助我?我的代碼如下:帶有錯誤密碼的登錄按鈕轉到下一個視圖

-(IBAction)enterCredentials 
{ 
    if ([[credtialsDictionary objectForKey:usernameField.text]isEqualToString:passwordField.text]) 
    { 
     UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"correct password" message:@"This password is correct." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil,nil]; 
     [alert show]; 
    } 
    else 
    { 
     UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Incorrect password" message:@"This password is incorrect." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil,nil]; 
     [alert show]; 
    } 
} 
+0

能否請你把一些代碼在這裏,我們可以看到什麼是錯在你的代碼。 – 2014-10-20 06:05:52

+0

顯示允許您導航到下一頁的代碼。以上代碼僅包含警報。 – Rumin 2014-10-20 06:11:01

+0

無論您發佈什麼內容,它都會起作用。也許你可以發佈更多的代碼,所以我們可以幫助你。 – Veeru 2014-10-20 06:11:18

回答

2

您需要實現

- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender  

方法來取消或允許SEGUE發生。

0

它看起來像你已經創建了segue鏈接UIButton點擊事件到下一個故事板UIViewController,所以你會做什麼,它會推到下一個控制器。

轉到Storybord

  1. 取下故事板是賽格瑞,做從代碼推導航。

enter image description here

  • 選擇下一個UIViewController並給獨特故事板ID像下面參考圖像。
  • enter image description here

  • 轉到控制器從那裏-(IBAction)方法正在調用類。
  • 在該方法中創建下一個視圖控制器的實例。
  • 更新代碼如下:

    -(IBAction)enterCredentials 
    { 
        if ([[credtialsDictionary objectForKey:usernameField.text]isEqualToString:passwordField.text]) 
        { 
         UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"correct password" message:@"This password is correct." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil,nil]; 
         [alert show]; 
    
         UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@「ViewController」]; 
         [self.navigationController pushViewController:controller animated:YES]; 
        } 
        else 
        { 
         UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Incorrect password" message:@"This password is incorrect." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil,nil]; 
         [alert show]; 
        } 
    } 
    
    相關問題