ios - how to do the same button for three screens? -


i have trouble. have avplayer , uibutton play/stop. also: have 3 uiviewcontrollers. need when click on first button on first uiviewcontroller on second controller, third controller button pressed also, respectively, on contrary, too. how make? proposition?

it's simple code - push on button - play url stream , when push again stop music.

-(ibaction)playradiobutton:(id)sender {     if(clicked == 0) {             clicked = 1;         nslog(@"play");         nsstring *urladdress = @"http://urlradiostream";         nsurl *urlstream = [nsurl urlwithstring:urladdress];         myplayer = [[avplayer alloc] initwithurl:urlstream];         [myplayer play];         [playradiobutton settitle:@"pause" forstate:uicontrolstatenormal];     }     else     {         nslog(@"stop");         [myplayer release];         clicked = 0;         [playradiobutton settitle:@"play" forstate:uicontrolstatenormal];     } } 

if have several controllers need notify event on controller can use nsnotificationcenter

eg. in 1 controller in viewdidload

[[nsnotificationcenter defaultcenter]    addobserver:self                                              selector:@selector(playbtnclicked:)                                                 name:@"btn_clicked"                                               object:nil];  

also in same controller define selector e.g.

-(void)playbtnclicked:(nsnotification *)pnotification { // } 

in other controller trigger using

    [[nsnotificationcenter defaultcenter]                      postnotificationname:@"btn_clicked" object:nil]; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -