Question

I am following the book, iOS Programming Big Nerd Ranch Guide, and I have come to a lesson where I am to create a custom view, HypnosisView. Now, I am suppose to have this view change it's color on shake, but it says I am suppose to make it the First-Responder.

I used,

- (BOOL)canBecomeFirstResponder
{
    return YES;
}

and

BOOL success = [view becomeFirstResponder];
if (success) {
    NSLog(@"HypnosisView became the first responder"):
} else {
    NSLog(@"Could not become first responder");
}

However, whenever I run my app, it always says that it could not become the first responder.

Any help would be appreciated.

UPDATE

I forgot to mention I get this output message.

Application windows are expected to have a root view controller at the end of application launch

Was it helpful?

Solution

Alright. I figured it out. I needed to put the delegate method

- (BOOL)canBecomeFirstResponder
{
    return YES;
}

In the CustomView.m file, not my App Delegate file. Easy fix.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top