2015-04-08 30 views
0
@IBAction func savePicture(sender: AnyObject) { 

     UIGraphicsBeginImageContextWithOptions(mainImageView.frame.size,false,0.0) 
     mainImageView.layer.renderInContext(UIGraphicsGetCurrentContext()) 
     let image = UIGraphicsGetImageFromCurrentImageContext() 
     UIGraphicsEndImageContext() 

     let alert = SCLAlertView() 

     alert.addButton("YES", action: { 
      UIImageWriteToSavedPhotosAlbum(image,nil,nil,nil) 
      //Save pop success tips 
      let alert1 = SCLAlertView() 
      alert1.showSuccess(self, title: "Saved successfully", subTitle: "^_^", closeButtonTitle: "OK", duration: 0) 

      //I want to link to another View controller 
     }) 

     alert.showInfo(self, title: "Okay to save?", subTitle: "Pictures will be saved to the album", closeButtonTitle: "NO", duration: 0) 
     } 

我需要鏈接到另一個TableViewController後,他們已經成功地保存在照片庫中的圖片。斯威夫特imageview的控制器需要幫助的另一個視圖控制器

**我曾嘗試推動這個代碼,但它不工作

var VC1 = self.storyboard?.instantiateViewControllerWithIdentifier("MyViewController") as ViewController 
      let navController = UINavigationController(rootViewController: VC1) // Creating a navigation controller with VC1 at the root of the navigation stack. 
      self.presentViewController(navController, animated:true, completion: nil) 

請幫我謝謝!

+0

你不能只執行一個segue嗎? –

+0

你是否想將圖像傳遞給下一個視圖控制器? – iAnurag

+0

我們需要更多信息。什麼沒有奏效?你看到了什麼?是否有任何錯誤輸出到控制檯? – dasdom

回答

0

你的邏輯被破壞了。 UIImageWriteToSavedPhotosAlbum也可能失敗,因此存在completionTargetcompletionSelector。你應該檢查它們。

因爲你確實使用故事板,所以最簡單的方法是在故事板中用某個名字創建segue。假設show-image。然後你只需撥打performSegueWithIdentifier("show-image", sender: image)即可。其中image是您想要通過的圖像的一些參考(如果您想要的話)。如果你不想傳遞圖像,只需在那裏通過nil

然後覆蓋prepareForSegue,檢查是否segue.identifier等於show-image,然後指定你的image引用(sender在這種情況下)一些segue.destinationViewController財產。

但是很難提供幫助或者更具體,因爲您沒有提供有關錯誤的更多細節。

+0

這是一個混亂:-)但是你的'MemeEditor'故事板ID是在Storyboard的'UINavigationController'中設置的,而不是你想要的'AddTableViewController'。 – robertvojta

+0

我已經嘗試過,但它仍然沒有工作。 –

相關問題