所以我有一个TableView
,用户可以按住每个单元格来查看视频/图像。按住部分可以工作,但是当我发布时它不会回到TableView
。
下面是用视频/图像显示视图的代码:
func playVideo() {
// get path and url of movie
let path = NSBundle.mainBundle().pathForResource("static2", ofType:"mov")
println(path)
let url = NSURL.fileURLWithPath(path!)
var moviePlayer = MPViewController()//took out video handling right now so this is just basically a regular view controller
moviePlayer.navController = self.navigationController
// construct the views
moviePlayer.addGestRecognizer()
self.navigationController.pushViewController(moviePlayer, animated: true)
}
然后我将这个手势识别器添加到视图单元格中:
let singleTap = UILongPressGestureRecognizer(target: self, action: Selector("tapped:"))
self.addGestureRecognizer(singleTap)
这里是“tapped:”函数:
func tapped(gestureRecognizer:UIGestureRecognizer){
println("held down")
if gestureRecognizer.state == UIGestureRecognizerState.Began {
playVideo()
}
if gestureRecognizer.state == UIGestureRecognizerState.Ended {
println("hold ended")
self.navigationController.popViewControllerAnimated(true)
}
//playVideo()
}
出于某种原因,一旦我将视图控制器推到主导航控制器上,我就不再得到“保持结束”。我怎样才能设置它以使它像Snapchat一样工作?
答案 0 :(得分:0)
这不是您要求的解决方案,但另一个想法是,您可能需要考虑使用UIView
而不是UIViewController
来展示媒体文件。
希望有所帮助:)