///属性记录电话 打来中断
private var centerPhone : CTCallCenter!
///电话进来 暂停音乐和继续音乐
private func phoneMusic() {
///监听电话
centerPhone = CTCallCenter()
///设置回调
weak var weakSelf = self ///这里注意弱引用 避免循环
centerPhone.callEventHandler = { (call:CTCall) -> Void in
if call.callState == CTCallStateIncoming {
print("电话来了")
return
}
if call.callState == CTCallStateDisconnected {
print("电话结束了")
return
}
}
}
-
看我那么可爱n(≧▽≦)n
- 关注我的微薄 (梁同桌):http://weibo.com/tongrenyinsheng
- 个人网站(同人音声) http://www.tongrenyinsheng.com
- ios 个人写的app (同人音声)ASMR音乐