A lot of things are a little uncomfortable. Here, Mark
First, delayed Initialization
First
@ Property (retain, nonatomic) nsmutablearray * buttonsarray;
@ Synthesize buttonsarray;
// Mark code-(nsmutablearray *) buttonsarray {If (! Buttonsarray) {buttonsarray = [[nsmutablearray alloc] init];} return buttonsarray ;}
Uinewsdetailplayview * newsdetailplayview = [[uinewsdetailplayview alloc] initfromnib]; [self. buttonsarray addobject: newsdetailplayview];
Add the object to the array, that is, to save the pointer.
For (uinewsdetailplayview * detailplayview in self. buttonsarray) {[detailplayview. playbutton setselected: No]; // retrieve playbutton and set the selected state}
Why do you want to write it like this? An error occurred while manually adding an event to a button.CodeAs follows:
[Newsdetailplayview. playbutton addtarget: Self action: @ selector (playaudio :) forcontrolevents: uicontroleventtouchupinside];
However, when playaudio declares an nstdio, you cannot perform the following operations on playbutton:
-(Void) playaudio :( uibutton *) button {int audioflag = button. tag-play_button_root_tag; nsarray * List = [self. newsdata. programamedia componentsseparatedbystring: @ ","]; nsstring * mediaurl = [list objectatindex: audioflag]; If (button. selected) {[[mmsplayer sharedmmsplayer] Stop]; [Button setselected: No]; isplaying = false;} else {[self startloadinganimation]; [[mmsplayer sharedmmsplayer] Play: mediaurl]; [Button setselected: Yes]; isplaying = true; // mark code [[nstimer scheduledtimerwithtimeinterval: 10 target: Self selector: @ selector (handletimer :) userinfo: Nil repeats: no] retain] ;}}- (void) handletimer :( nstimer *) timer {// mark code for (uinewsdetailplayview * detailplayview in self. buttonsarray) {[detailplayview. playbutton setselected: No];} [alertutils alertwithmessage: @ "buffer timeout check whether network resources are available"]; [[mmsplayer sharedmmsplayer] Stop]; [self stoploadinganimation]; [Timer release];}