(ObjCですが)ここに書いてあるように一旦ファイルに保存して画像データを渡す代わりにファイルのURLを渡せば、URLのファイル名で受け渡せます。
Swift
1let docsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first!
2// The file extension is important so that some mime magic happens!
3let filePath = (docsPath as NSString).stringByAppendingPathComponent("test.png")
4let fileUrl = NSURL(fileURLWithPath: filePath)
5
6UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, 0)
7view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true)
8let image = UIGraphicsGetImageFromCurrentImageContext()
9UIGraphicsEndImageContext()
10let data = UIImagePNGRepresentation(image)!
11data.writeToURL(fileUrl, atomically:true) // save the file
12
13// Now pass the file URL in the activity items array
14let avc = UIActivityViewController(activityItems: ["Here's an attached PNG", fileUrl], applicationActivities: nil)
15self.presentViewController(avc, animated:true, completion: nil)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/02/03 10:23