objective c - Is there a way to pass additional data to UserInfo dictionary using NSNotificationCenter with UIKeyboardDidShowNotification -
i have these lines of code:
-(void)somemethod:(uiscrollview*)scrollview{ [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(keyboardwasshown:) name:uikeyboarddidshownotification object:nil]; } -(void)keyboardwasshown:(nsnotification *)anotification{ // want scrollview on here }
is there way make possible? i've tried perform staff according
but anotification.userinfo doesn't contain data
[[nsnotificationcenter defaultcenter] postnotificationname:uikeyboarddidshownotification object:self userinfo:@{@"scrollview":scrollview}];
you listening uikeyboarddidshownotification
, post uikeyboardwillhidenotification
won't work. first maybe create own notification name i.e xyzkeyboarddidshownotification
, register , post using name additional data want. , can do:
-(void)keyboardwasshown:(nsnotification *)anotification{ uiscrollview *scrollview = anotification.userinfo[@"scrollview"]; }
Comments
Post a Comment