Swift实战-豆瓣电台(九)简单手势控制暂停播放(全文完)
Swift实战-豆瓣电台(九)简单手势控制暂停播放
全屏清晰观看地址:http://www.tudou.com/programs/view/tANnovvxR8U/
这节我们主要讲UITapGestureRecognizer和MPMoviePlayerController
知识点
UITapGestureRecognizer
关联storyboard上的UITapGestureRecognizer
@IBOutlet var tap:UITapGestureRecognizer=nil //注意要设置为nil
增加手势识别
addGestureRecognizer(tap)
移除手势识别
removeGestureRecognizer(tap)
关联Action
@IBAction func onTap(recognizer: UITapGestureRecognizer)
通过recognizer.view可以判断点击了哪个组件
@IBAction func onTap(recognizer: UITapGestureRecognizer){ if recognizer.view==btnPlay { btnPlay.hidden=true audioPlayer.play() btnPlay.removeGestureRecognizer(tap) iv.addGestureRecognizer(tap) }else if recognizer.view==iv { btnPlay.hidden=false audioPlayer.pause() btnPlay.addGestureRecognizer(tap) iv.removeGestureRecognizer(tap) } }
MPMoviePlayerController
播放
play()
暂停
pause()
本节高清视频和代码下载地址
http://pan.baidu.com/s/1sjHd5qX
这个系列全部结束了,谢谢观赏 ^_^
转载请注明出处,我的博客:http://www.cnblogs.com/sandal1980/
Swift实战-豆瓣电台系列