這個問題在昨天的讀書會之後,終於有了解答!
我的問題是使用Storyboard來進行畫面切換,
畫面是使用者登入的畫面,
當使用者輸入正確的登入資料時,
畫面才會跳轉到下一畫面,
若輸入資料錯誤則提示訊息。
部分程式碼如下:
- (IBAction)loginButtonPressed:(id)sender {
NSLog(@"[userNameTextField text] = %@",[userNameTextField text]);
NSLog(@"[passwordTextField text] = %@",[passwordTextField text]);
if ([[userNameTextField text] isEqualToString:userName] && [[passwordTextField text] isEqualToString:password]) {
[self performSegueWithIdentifier:@"loginSuccess" sender:self];
} else {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Login Fail" message:@"Please Check Your User Name or Password.\n It's Wrong." delegate:self cancelButtonTitle:@"OK!" otherButtonTitles:nil, nil ];
[alertView show];
}
}
另外如果希望再切換畫面前在做某些事
可以實現以下Method
- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
//寫上你想執行的...
}