2014-10-20 2 views
0

Я создаю имя пользователя и пароль с помощью кнопки входа в систему. Когда я ввожу неправильный пароль, появляется предупреждающее сообщение. Но оно также переходит к следующим страницам. Коды ниже:пароль ошибки также переходит на следующую страницу в xcode 5

- (void)viewDidLoad 
    { 
     [super viewDidLoad]; 
     // Do any additional setup after loading the view, typically from a nib. 

     _myDict=[[NSDictionary alloc]initWithObjects:[NSArray arrayWithObjects:@"alex",@"aliv", nil] forKeys:[NSArray arrayWithObjects:@"123",@"ece", nil]]; 

    } 
    - (IBAction)loginbtn:(id)sender { 
     [self performSegueWithIdentifier:@"segue1" sender:self]; 
     } 


    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
     if ([segue.identifier isEqualToString:@"segue1"]) { 
       checkviewcontroller *dest1 = segue.destinationViewController; 


     } 
    } 

и

-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { 
    if ([identifier isEqualToString:@"segue1"]) { 
    if([[self.myDict objectForKey:_text2.text]isEqualToString:_text1.text]){ 
    UIAlertView *myAlert=[[UIAlertView alloc]initWithTitle:@"ALERT MESSAGE" message:@"correct Password" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil]; 
        [myAlert show]; 
} 
else{ 

    UIAlertView *myAlert=[[UIAlertView alloc]initWithTitle:@"ALERT MESSAGE" message:@"Verify your Password" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil]; 
        [myAlert show]; 

       } 

       return NO; 
      } 

      return YES; 
     } 

ответ

0

Вы возвращающая YES в блоке еще после проверки на соответствие пароль при любом случае.

Я думаю, что это то, что вы ищете .:

if ([identifier isEqualToString:@"segue1"]) { 

       if([[self.myDict objectForKey:_text2.text]isEqualToString:_text1.text]){ 
        UIAlertView *myAlert=[[UIAlertView alloc]initWithTitle:@"ALERT MESSAGE" message:@"correct Password" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil]; 
        [myAlert show]; 

        return YES; 
       } 
       else{ 

        UIAlertView *myAlert=[[UIAlertView alloc]initWithTitle:@"ALERT MESSAGE" message:@"Verify your Password" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil]; 
        [myAlert show]; 

        return NO; 

       } 
    } 

    return NO; 

`

+0

yes.I changed.still ошибка passwor –

+0

еще ошибка PWD переходит к следующему page.how я могу избежать этого? –