Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios becomeFirstResponder失败_Ios_Objective C_Cocoa Touch - Fatal编程技术网

Ios becomeFirstResponder失败

Ios becomeFirstResponder失败,ios,objective-c,cocoa-touch,Ios,Objective C,Cocoa Touch,我有一个简单的问题: 如何设置代码使NSObject成为第一响应者?在我的代码中,我将此代码放入AppDelegate,但该AppDelegate未能成为第一响应者。如果我试图让另一个NSObject成为第一响应者,我也会遇到同样的情况 //This function is called when app enters background - (void)prepareRemoteControlEventsListener{ //register for remote control

我有一个简单的问题:

如何设置代码使NSObject成为第一响应者?在我的代码中,我将此代码放入AppDelegate,但该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;
}

让appdelegate作为第一响应者,您将实现什么?现在调用此应用程序内委托可能还为时过早,因为视图不在层次结构中是的您的appdelegate是UIResponder的子类?Emmanuel,appdelegate是每个应用程序的UIResponder,不是吗?rajesh,我试图通过调用beginReceivingRemoteControlEvents来接收远程控制事件