【发布时间】:2014-10-05 09:28:45
【问题描述】:
我正在制作一个受 iOS8 语音消息启发的应用程序,并尝试添加“手势和动画(例如向左滑动并取消记录,向右滑动以上传语音记录。)”,但它根本不起作用。下面是sn-p的代码。
// Swipe left and cancel
let swipeLeftGesture = UISwipeGestureRecognizer(target: self, action: "swipeLeftCancel")
swipeLeftGesture.direction = UISwipeGestureRecognizerDirection.Left
self.view.addGestureRecognizer(swipeLeftGesture)
// Swipe right and upload
let swipeRightGesture = UISwipeGestureRecognizer(target: self, action: "swipeRightUpload")
swipeRightGesture.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(swipeRightGesture)
session.requestRecordPermission({(granted: Bool)-> Void in
if granted {
self.setupRecorder()
} else {
println("Permission to record not granted")
}
})
func swipeLeftCancel(sender: UISwipeGestureRecognizer) {
// slide left and cancel
}
func swipeRightUpload(sender: UISwipeGestureRecognizer) {
// slide right and upload
)
整个代码(在添加 UISwipeGestureRecognizer 之前)在这里 ー> https://github.com/chansuke/GoForIt
有人给点建议吗?
【问题讨论】:
-
“根本不起作用”我猜你的意思是当你执行滑动手势时应用程序崩溃?
标签: xcode animation swift ios8 gesture