In viewDidLoad I check if two UITextFields have a valid input (text length > 0) and then I set the enabled property of an UIButton. Using the debugger I figured out that
self.loginButton.enabled = YES;
is executed, but when I print the boolean value with
print self.loginButton.enabled
I get NO before (which is okay) but also NO after the statement is executed. I also checked multiple times if the UIButton property of self is connected to the UIButton in my storyboard with an IBOutlet and that is the case. I can also print the text of the titleLabel with the console. When I tap one of the UITextFields and change the text
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
is being called and there I will check the text again. Here
self.loginButton.enabled = YES;
seems to work normally. With iOS 5 I don’t have any problems, but I didn’t found any relevant changes for iOS 6 in the documentation for this problem.
Any ideas?
Edit: The issue is something different. I also have a UITableView in that UIViewController and the tableView is bigger then expected (bigger then set in the Storyboard) at that point (until know I don’t know why) and seems to override the UIButton. Changing the frame of the UIButton or UITableView before executing
self.loginButton.enabled = YES;
works. There might be a delay when setting the enabled property, because printing the boolean value of still returns NO.
NSLog(@"%i",self.loginButton.isEnabled);
self.loginButton.enabled = YES;
NSLog(@"%i",self.loginButton.isEnabled);
2012-10-13 16:11:43.460 [1524:c07] 1
2012-10-13 16:11:43.462 [1524:c07] 1
The problem is that the UITableView is being resized from the initial size declared in the storyboard, because of autoresizing and then it covers the UIButton area. And a button hit was interpreted as interaction with the UITableView. Changing the UIButton frame, the UITableView frame or the autoresizing settings solves the problem.