0

나는 UISplitViewController방법의 ViewController를 표시하기 : UIImagePickController을하고 기각 (스위프트)

그것은 UIsplitviewcontroller이다,이 코드는 detailview에서 detailview가 호출되어에서의 ViewController 이잖아에서 의를 uipickerviewcontroller로드이 uiactionsheet있어 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 
} 

갈 나던 : 경고 : 시도를 이미 (널) 내가이 사용하는 경우

방법 적있는 제시를 제시 : self.showDeatilViewController을 (imagePicker 사실)가 표시하지만 내가 전혀 기각 할 수

여기

이 어떻게 내가 내가있는 viewDidLoad에서이 코드를 실행하면이

func imagePickerControllerDidCancel(picker: UIImagePickerController) { 

    picker.dismissViewControllerAnimated(true, completion: nil) 
} 

를 기각 될 것이라고 생각, 내가 알아 낸

 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) 

? 나는 그것이 작동있어 한

+0

무엇이 자기 안에 있습니까? – CW0007007

+0

@ CW0007007 그것은 uisplitviewcontroller에있어, 나는 언급을 잊어 버렸습니다 ... 어떻게 자기가 uisplitviewcontroller의 Detailviewcontroller라고 생각합니까? – KennyVB

+0

분할보기의 마스터보기입니까? – CW0007007

답변

4

는 ... 누군가가 8.0 IOS는 photolibery을 열기로 버그가 나의 관심을 끌게와 같은 응용 프로그램에서 .. 그래서 나는이

dispatch_async(dispatch_get_main_queue()){ 
     imagePicker.delegate = self 
     self.presentViewController(imagePicker, animated: true, completion: nil) 
    } 
같은 주요 큐에 넣어

그리고 이제 작동합니다!

조금 지연되었지만 작동합니다.