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

how pass nsdictionary postnotificationname:object:

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

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -