Reputation:
I have a tableview
,and in that tableview
i am setting customcell
.in that customcell
have a button,when button click then delegate method called and play or pause audio.
But i dont know why my method does not called.
here is my code.
AudioInfoCell.h //itas child view
#import <UIKit/UIKit.h>
@protocol PlayPauseDelegate <NSObject>
-(void)playPauseAudio;
@end
@interface AudioInfoCell : UITableViewCell
{
id<PlayPauseDelegate> delegate;
}
@property(nonatomic,strong)id delegate;
@end;
AudioInfoCell.m
@synthesize delegate;
- (IBAction)playPauseBtnTapped:(id)sender {
if([delegate respondsToSelector:@selector(playPauseAudio)])
{
//send the delegate function with the amount entered by the user
[delegate playPauseAudio];
}
}
AudioTableViewController.h //its parent view
#import "AudioInfoCell.h"
@interface AudioTableViewController : UIViewController<PlayPauseDelegate>
AudioTableViewController.m
cell.delegate = self;
-(void)playPauseAudio{
NSLog(@"button pressed");
}
Upvotes: 0
Views: 168
Reputation: 9143
@kartik , i you have not specified in which method you have specifies cell.delegate=self;
.
so i assume that you have specified it in viewDidLoad
,instead of that specify it in vieWillApear
method than it should work.
Upvotes: 1