0
私は、ユーザーが落とした地図ピンに最大3枚の画像を添付できるようにしています。現在、UIViewに表示される添付画像を表示するための小さなプレビューがあります。プレビューボタンを押すと、ユーザーにフルスクリーンイメージを表示させようとしています。下の画像プレビューボタンの例です。ここで一度画像をフルスクリーンで表示ボタンを押したとき
は、関連するコードです:
// Image preview
img1 = UIButton(frame:TCRectMake(x: 18,y:82,width:80,height:110))
img1.backgroundColor = UIColor.clearColor()
img1.contentMode = .ScaleAspectFill
img1.clipsToBounds = true
img1.addTarget(self, action:"selectImage:", forControlEvents: UIControlEvents.TouchUpInside)
popupView.addSubview(img1)
img2 = UIButton(frame:TCRectMake(x: 100.8,y:82,width:80,height:110))
img2.backgroundColor = UIColor.clearColor()
img2.contentMode = .ScaleAspectFill
img2.clipsToBounds = true
img2.addTarget(self, action:"selectImage:", forControlEvents: UIControlEvents.TouchUpInside)
popupView.addSubview(img2)
img3 = UIButton(frame:TCRectMake(x: 183,y:82,width:80,height:110))
img3.backgroundColor = UIColor.clearColor()
img3.contentMode = .ScaleAspectFill
img3.clipsToBounds = true
img3.addTarget(self, action:"selectImage:", forControlEvents: UIControlEvents.TouchUpInside)
popupView.addSubview(img3)
...
// Save image to document
func saveImageIntoDocument(resizeImage:UIImage,saveCompleted:((String)->())? = nil)
{
let documentsUrl = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first!
let timeStamp = "\((Int(Timestamp))).png"
let filePath = documentsUrl.relativePath!.stringByAppendingString("/\(timeStamp)")
if saveCompleted != nil
{
saveCompleted!(timeStamp)
}
UIImagePNGRepresentation(fixRotation(resizeImage))!.writeToFile(filePath, atomically: true)
}
これは、各プレビューボタンのコードです:
func image1Click(sender:UIButton)
{
print(sender.tag)
}
func image2Click(sender:UIButton)
{
print(sender.tag)
}
func image3Click(sender:UIButton)
{
print(sender.tag)
}
私は私は何かが逃したかどうかを知ってみましょう:)もし誰かがプレビューを見るのを助けることができたフルスクリーンは素晴らしいだろう!
お返事のおかげで、何も私が実装したときに、これはたぶん私は間違って何か?それは行くべきをやっている:(起こるようですか? – Oscar
画像がどこにあるかそれはのViewControllerに行く必要があります。 –
はい、私はそれを置きますあなたが返信してくれてありがとうございました – Oscar