ios - NSNotification register place issue -
i have tab bar application in there 2 tabs(2 view controllers). need post notification tab 2(view controller 2) tab 1(view controller 1). problem have first go tab 1(view controller 1) in order register notification, if dont notification never registered. seems view allocated once select , move tab 2(view controller 2) post notification.
in register notification in viewdidload , viewwillappear this:
[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(createyourownpressed:) name:@"createyourownpressed" object:nil];
so, how can avoid first selecting tab 1(view controller 1) , post notification tab 2(view controller 2)?
thanks!!
if have instances of view controllers in tabs in appdelegate try in applicationdidfinishlaunching
[[nsnotificationcenter defaultcenter] addobserver:tab1viewcontroller selector:@selector(createyourownpressed:) name:@"createyourownpressed" object:nil];
or this, while adding view controller uitabbarcontroller
viewcontroller *vc=[[viewcontroller alloc]initwithnibname:@"viewcontroller" bundle:nil]; [[nsnotificationcenter defaultcenter] addobserver:vc selector:@selector(createyourownpressed:) name:@"createyourownpressed" object:nil];
Comments
Post a Comment