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