プログラムで UIButton を作成し、関数を追加しました。実行時に応答しません。
scrollViewFrame = CGRectMake(10, 110, 300, 40);
loginBut = [UIButton buttonWithType:UIButtonTypeRoundedRect];
loginBut.frame = scrollViewFrame;
loginBut.backgroundColor = [UIColor whiteColor];
loginBut.titleLabel.font = [UIFont fontWithName:@"Trebuchet MS" size:33];
[loginBut setTitleColor:[UIColor Gray] forState:UIControlStateNormal];
[loginBut setTitle:@"Login" forState:UIControlStateNormal];
[loginBut setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
[loginBut addTarget:self
action:@selector(checkError)
forControlEvents:UIControlEventTouchUpInside];
self.loginBut = loginBut;
[self.view addSubview:loginBut];
アクション:
- (void)checkError {
if ([dispName.text isEqualToString:@""]&&[pw.text isEqualToString:@""]) {
UIAlertView *alertFailed = [[UIAlertView alloc]initWithTitle:@"\nError" message:@"1. Display Name missing.\n2. Password missing." delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
[alertFailed show];
}
}
事前にサンクス...