In my view controller I have initialized a new UIView Subclass called HypnosisView and added it to the root view of the ViewController. And in viewDidLoad I set the view to become the first responder like so:
- (void)viewDidLoad
{
[super viewDidLoad];
HypnosisView *view2 = [[HypnosisView alloc] initWithFrame:[[self view] bounds]];
[self.view addSubview:view2];
BOOL success = [view2 becomeFirstResponder];
if (success) {
NSLog(@"HypnosisView became the first responder");
} else {
NSLog(@"Could not become first responder");
}
}
I also overrode the method canBecomeFirstResponder in the UIView HypnosisView.m file like so:
- (BOOL)canBecomeFirstResponder
{
return YES;
}
Now when I run the program I am expecting the console to report "HypnosisView became the first responder" but it reports "Could not become first responder."
BUT
when I shake the device the view does respond to the shake event! So it looks like it actually became the first responder but it is reporting it did not become first responder. Such a strange issue, please help!