2017-06-06 61 views
0

我試圖DKImagePickerController融入我的項目。DKImagePickerController致命錯誤:意外發現零而展開的可選值

GitHub的是在這裏: DKImagePickerController

我做的CocoaPods更新。該示範項目是罰款運行,但我的項目有錯誤,當我點擊按鈕的照片庫的視圖:

unexpectedly found nil while unwrapping an Optional value

func showImagePicker() { 
     pickerController.defaultSelectedAssets = self.assets /* this one 
If anyone know what wrong, I appreciate it*/ 

回答

0

對象的第一行pickerController只聲明,未初始化。 SDK的指導頁面已經給出了示例,並且我爲您的情況更改了一些行:

func showImagePicker() { 
    if pickerController == nil { 
     pickerController = DKImagePickerController() 
    }  

    pickerController.defaultSelectedAssets = self.assets 
    pickerController.didSelectAssets = { (assets: [DKAsset]) in 
     self.assets = assets 
     //Continue handle images which in the assets. 
    } 

    self.presentViewController(pickerController, animated: true) {} 
} 
+0

感謝您的回覆。我仍然無法解決問題。這有點複雜,因爲資產是由NSObject組成的DKassest數組。我真不知道在哪裏以及如何啓動pickerController = DKImagePickerController()。你可以請更具體嗎? – Tinh

+0

@Tinh,答案已更新。 –

+0

謝謝,謝謝。你是我的救星。 – Tinh

相關問題