入力したパスワードが正しい場合、ログイン ビューからメイン ビューに変更する必要がある iPhone アプリのログイン画面を作成しましたが、if ステートメントでビューを変更する方法がわかりません。これまでのところ(それほど多くはありません、私は知っています)
#import "ViewController.h"
#import "MainViewViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (IBAction)enterPassword
{
NSString *passwordString = [NSString stringWithFormat:@"12345"];
if ([passwordField.text isEqualToString:passwordString]) {
}
else {
UIAlertView *correctPassword = [[UIAlertView alloc] initWithTitle:@"Falsches Passwort" message:@"Dieses Passwort ist falsch! Geben Sie bitte das korrekte Passwort ein!" delegate:self cancelButtonTitle:@"Zurück" otherButtonTitles:nil, nil];
[correctPassword show];
}
}
- (IBAction)switchView:(id)sender {
MainViewViewController *main = [[MainViewViewController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:main animated:YES completion:NULL];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
これは ViewController.m ファイル全体であり、switchview アクションを if ステートメントに入れたいと考えています。if ステートメントでビューを変更するにはどうすればよいですか。
パトリックに感謝します。