搜尋此網誌

2012年9月6日 星期四

監聽TextField change


.h

@property (strong, nonatomic) IBOutlet UITextField *account;
@property (strong, nonatomic) IBOutlet UITextField *password;

@property (strong, nonatomic) IBOutlet UITextField *displayAccount;
@property (strong, nonatomic) IBOutlet UITextField *displayPassword;



.m
- (void)viewDidLoad
{
//建立監聽事件


    [displayAccount addTarget:self action:@selector(onAccountChange) forControlEvents:UIControlEventEditingChanged];
    [displayPassword addTarget:self action:@selector(onPasswordChange) forControlEvents:UIControlEventEditingChanged];
}


-(void) onAccountChange{
    account.text=displayAccount.text;
}
-(void) onPasswordChange{
    password.text=displayPassword.text;
}

沒有留言:

張貼留言