小编Ste*_*rck的帖子

在Swift中检测UIImageView Touch

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)

uiimageview ios swift

13
推荐指数
3
解决办法
2万
查看次数

Sharing Gifs Swift

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 ios uiactivityviewcontroller swift

3
推荐指数
1
解决办法
1823
查看次数

didSelectItemAtIndexPath在集合视图Swift中不起作用

我一直在研究一个新的应用程序,它在集合视图中显示Gif.我也在我的集合视图中为单元格使用自定义集合视图单元类.

该方法didSelectItemAtIndexPath虽然不起作用......

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {

    println("it worked")

    // ^this did not print
}
Run Code Online (Sandbox Code Playgroud)

我如何更改它以便我可以使用手势识别器获取所单击项目的indexPath?

objective-c ios uicollectionview uicollectionviewcell swift

2
推荐指数
1
解决办法
6169
查看次数

从API转换Swift中String中的任何UTF-8编码字符

我正在制作一个应用程序,用于检查我学校的成绩和作业.在查看作业时从网上看到: 来自学校网页的图像

但是服务器实际上返回一个包含常规字符的字符串,而中文字符保持常规的UTF-8编码格式: 应用程序中显示的原始字符串

我将如何解析Swift中的原始String并解码任何UTF-8编码的字符..我很难找到甚至在网上找到解决方案.只是一个FYI,我无法改变后端的任何内容.

string utf-8 nsstring ios swift

0
推荐指数
1
解决办法
8181
查看次数