当UIImageView
触摸时你会如何检测并运行动作?这是我到目前为止的代码:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
var touch: UITouch = UITouch()
if touch.view == profileImage {
println("image touched")
}
}
Run Code Online (Sandbox Code Playgroud) How would I share a Gif in Swift? The method I am using right now to share the Gif URL only shares one image and does not share the animated Gif image. Here is what I have right now:
var cell = self.collectionView.cellForItemAtIndexPath(index)
println(index.item)
var URLString: String = contentArray[index.item].contentUrlStirng
var shareURL: NSURL = NSURL(string: "\(URLString)")!
var shareImage: UIImage = UIImage.animatedImageWithAnimatedGIFURL(shareURL)
let firstActivityItem: Array = [shareImage]
let activityViewController:UIActivityViewController = UIActivityViewController(activityItems: firstActivityItem, applicationActivities: nil)
self.presentViewController(activityViewController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
The URLString
contains …
我一直在研究一个新的应用程序,它在集合视图中显示Gif.我也在我的集合视图中为单元格使用自定义集合视图单元类.
该方法didSelectItemAtIndexPath
虽然不起作用......
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
println("it worked")
// ^this did not print
}
Run Code Online (Sandbox Code Playgroud)
我如何更改它以便我可以使用手势识别器获取所单击项目的indexPath?