- 长按手势多次触发
最近在做新浪第三方分享的时候无论是简单的添加一个长按手势,还是在cell上添加长按手势,再触发方法后总是调用不止一次,处理方法如下:
func longPressGestureAction(gesture:UIGestureRecognizer) {
if gesture.state == .began {
let alert = UIAlertView(title: "分享到新浪微博", message: NSStringFromClass((gesture.view?.classForCoder)!), delegate: nil, cancelButtonTitle: "确定")
alert.show()
}
}
//NSData转换为UIImage
NSData *imageData = [NSData dataWithContentsOfFile: imagePath];
UIImage *image = [UIImage imageWithData: imageData];
//UIImage转换为NSData
NSData *imageData = UIImagePNGRepresentation(aimae);