方法一:
self.isPlayOrPause=YES;
UIView *spbg=[[UIViewalloc]initWithFrame:CGRectMake(10,10,self.contentView.frame.size.width-20,290)];
spbg.backgroundColor=[UIColorblueColor];
//播放按鈕
UIButton *playBtn=[UIButtonbuttonWithType:UIButtonTypeCustom];
playBtn.bounds=CGRectMake(0,0,60,60);
playBtn.center=spbg.center;
[playBtn setImage:[UIImageimageNamed:@"bf"]forState:UIControlStateNormal];
self.palyBtn=playBtn; [playBtn addTarget:self action:@selector(changeToplayOrPause) forControlEvents:UIControlEventTouchDown];
videoWnd_ = [[DHVideoWndalloc]initWithFrame:CGRectMake(10,10,self.contentView.frame.size.width-20,290)];
[spbg addSubview:videoWnd_];//添加視頻播放
[self.contentViewaddSubview:spbg];
[self.contentView addSubview:playBtn];
===============================-(void)changeToplayOrPause{
self.isPlayOrPause=!self.isPlayOrPause;
if(self.isPlayOrPause==NO){
[selfonBtnPlay:nil];//播放
self.palyBtn.alpha=0;
}else{
[selfonBtnPause:nil];//暫停
self.palyBtn.alpha=1;
}
NSLog(@"-self.isPlayOrPause---%tu",self.isPlayOrPause);
}
最關(guān)鍵的是:按鈕要添加到cell的content view上。否則點(diǎn)擊不會(huì)生效。方法二:用代理(網(wǎng)上講的比較多,自己搜索)方法三:用tag值;方法四:在cell上添加一層imageView,然后在imageView上添加按鈕,(之前試過可以用,最近一次又不行了,哪位測(cè)試可以用通知聲)新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注