becomeFirstResponder失败

时间:2014-04-07 04:40:30

标签: ios objective-c cocoa-touch

我有一个简单的问题:

如何设置代码让NSObject成为第一个响应者?在我的代码中,我将此代码放入AppDelegate,但应用程序委托未能成为第一个响应者。如果我试图让另一个NSObject成为第一个响应者,那么同样发生在我身上。

//This function is called when app enters background
- (void)prepareRemoteControlEventsListener{

    //register for remote control
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

    // Set itself as the first responder
    BOOL success = [self becomeFirstResponder];
    if (success) {
        NSLog(@"APP degelgate AVManager for remote control events");
    }else{
        NSLog(@"@@@ degelgate failed to listen remote control events @@@");
    }
}
//Suppose it should enable self becoming firstResponder?
- (BOOL)canBecomeFirstResponder{
    return YES;
}

0 个答案:

没有答案