我想在用戶插入正確的用戶名和密碼後轉到其他頁面。怎麼做 ? 第一個菜單是ViewController。第二種觀點是Utama。用戶名是從用戶名NSString和密碼獲取從密碼NSString。iOS - 如果有條件,轉到頁面
正確的用戶名是 「Andika」 和正確的密碼是1234
故事板
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *appTittle;
@property (weak, nonatomic) IBOutlet UITextField *usernameTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;
- (IBAction)okPressed:(id)sender;
ViewController.m
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (IBAction)okPressed:(id)sender {
NSString *username = [_usernameTextField text];
NSString *password = [_passwordTextField text];
if([username compare:@"andika"] && [password compare:@"1234"]) {
//????
}
}
@end
Utama.m
#import "Utama.h"
@interface Utama()
@end
@implementation Utama
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
更新:對不起,我是新手。我仍然不能去另一個頁面。
我給這樣
該標識符修改後的代碼在ViewController.m
如果比較字符串,你應該使用這個方法isEqualToString: – 2015-02-23 07:55:44
好的,謝謝重要信息 – 2015-02-23 08:14:54