First of all, this method is really very cow, it is better to ingenious:
In this app to do foodie, because we need to add a button on the UITableViewCell, when you click on this button to start playing audio (while the button status changed to selected), these processing is OK, But now the problem is that when the audio playback is complete, a proxy method is triggered (that is, telling the audio to be played
-(void) audioplayerdidfinishplaying: (Avaudioplayer *) player successfully: (BOOL) flag), how do I change the state of the button in this method:
Chat with the group of Brothers to know, I can define a global button, and then assign this button in the cell to the global button, when the audio playback is complete, in that proxy method to write button.selected = NO;
My code implementation is like this, just intercept fragments here:
In the. h file:
UIButton *btn;
@property (Nonatomic,retain) UIButton *btn;
In the. m file:
First-(void) The Dealloc method writes:
{
if (BTN) {//This place is what I have mentioned in the next article if not sure will be created, then in the Delloc release in the best judgment
[BTN release];
BTN = nil;
}
[Super Dealloc]; }
In
-(UITableViewCell *) TableView: (UITableView *) Tableviewdemo Cellforrowatindexpath: (Nsindexpath *) Indexpath In this method, the button of the cell is assigned to the global button:
SELF.BTN = Cell.audioinfobutton;
You can then change the status of the button in the proxy class where the audio playback is completed:
-(void) audioplayerdidfinishplaying: (Avaudioplayer *) player successfully: (BOOL) Flag {
NSLog (@ "play complete");
self.btn.selected = NO;
}