0

UISplitViewControllerにあるviewcontrollerにuipickerviewcontrollerをロードするこのuiactionsheetを取得しました

これは UIsplitviewcontroller です。このコードは詳細ビューにあり、詳細ビューは masterview から呼び出されます。

ただし、「クリック」してロードしようとすると、警告が表示され、それ以上進みません

   func actionSheet(actionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int){
    var imagePicker = UIImagePickerController()
    imagePicker.delegate = self

    switch buttonIndex{

    case 0:
        imagePicker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
        imagePicker.allowsEditing = true
        imagePicker.delegate = self
        NSLog("Vælg fra Biblioteket");
        break;
    case 1:
        imagePicker.sourceType = UIImagePickerControllerSourceType.Camera
        imagePicker.allowsEditing = true
        imagePicker.delegate = self
        NSLog("Vælg Kamera");
        break;
    default:
        NSLog("Default");
        break;
    }
    self.presentViewController(imagePicker, animated: true, completion: nil) // this is the problem 
}

警告は次のとおりです: 警告: Attempt to present on which is already presenting (null)

これを使用するとどうなりますか: self.showDeatilViewController(imagePicker, true) 表示されますが、まったく却下できません

これが私がそれが却下されると思った方法です

    func imagePickerControllerDidCancel(picker: UIImagePickerController) {

    picker.dismissViewControllerAnimated(true, completion: nil)
}

このコードをviewDidLoadで実行すると、動作します

        var imagePickerController = UIImagePickerController()
    imagePickerController.delegate = self
    imagePickerController.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
    imagePickerController.allowsEditing = true
    self.presentViewController(imagePickerController, animated: true, completion: { imageP in

    })

私がこれを書くと、私はそれを理解しました:

        self.presentedViewController?.presentViewController(imagePicker, animated: true, completion: nil)

表示して閉じる?!?!

4

1 に答える 1

4

私はそれを機能させました... 8.0 IOSにはアプリからフォトリベリなどを開く際のバグがあることに誰かが注意を向けました..だから私はそれをこのようにメインキューに入れました

dispatch_async(dispatch_get_main_queue()){
        imagePicker.delegate = self
        self.presentViewController(imagePicker, animated: true, completion: nil)
    }

そして今それは動作します!

少し遅れますが動作します

于 2014-10-04T08:03:51.390 に答える