Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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
Iphone 将数据发送到为通知注册的方法_Iphone_Cocoa Touch_Selector_Nsnotifications - Fatal编程技术网

Iphone 将数据发送到为通知注册的方法

Iphone 将数据发送到为通知注册的方法,iphone,cocoa-touch,selector,nsnotifications,Iphone,Cocoa Touch,Selector,Nsnotifications,我需要将一些数据传递给我正在注册的方法,以便在收到通知后执行 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:withCell:) name:UIKeyboardWillShowNotification object:nil]; 在这里,我想发送一些数据,用于我的方法的withCell部分 如何实现这一点?当您发布通知并希望传递一些数据时,请使用: - (voi

我需要将一些数据传递给我正在注册的方法,以便在收到通知后执行

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:withCell:) name:UIKeyboardWillShowNotification object:nil];
在这里,我想发送一些数据,用于我的方法的withCell部分


如何实现这一点?

当您发布通知并希望传递一些数据时,请使用:

- (void)postNotificationName:(NSString *)notificationName object:(id)notificationSender userInfo:(NSDictionary *)userInfo

但在您的情况下,这是系统通知,所以最好的选择是在视图控制器中注册回调,当显示键盘时将调用该回调(它只接收一个参数-NSNotification)。您必须使用一些ivar(例如selectedCell)并在回调中处理它。

简短回答:您不能。您正在注册通知,无法控制随该通知发送的内容


您想做什么?

通过此通知,我想将表格视图滚动到所选单元格。因此,我需要在表视图的contentSet中添加键盘高度。现在在通知回调中,我有我的表视图,但没有所选单元格的索引。