2016-09-20 3 views
1

이미지와 비디오를 여러 번 선택하려면 DKImagePicker을 사용하고 있습니다. 나는 이미지를 가져오고 있지만 비디오를 가져 오는 방법은 모르겠다.
지금까지 시도한 코드를 아래에 공유했습니다.
안내하십시오.DKAssets에서 비디오 가져 오기

func setImage() 
{   
    let pickerController = DKImagePickerController() 
    pickerController.showsCancelButton = true 
    pickerController.showsEmptyAlbums = false 

    pickerController.didSelectAssets = { (assets: [DKAsset]) in 
     print("didSelectAssets") 

     self.assets1 = assets 
     print(assets.count) 

     for asset in assets { 
      asset.fetchImageWithSize(PHImageManagerMaximumSize, completeBlock: { image, info in 
       if let img = image { 
        // let fixOrientationImage=img.fixOrientation() 

        User.sharedInstance.arrRoomGalleryImages.addObject(img) 
        print("array after selecting images and videos", User.sharedInstance.arrRoomGalleryImages) 

        kAppDelegate.imageSelected = true 
       } 
      }) 
     } 

    } 
    if(!(kAppDelegate.imageSelected)) 
    { 
     self.presentViewController(pickerController, animated: true)  {} 
    } 
} 
+0

내 대답 그것은 구문 오류 –

답변

0

DKAsset에는 isVideo 속성이 있습니다. 그것을 사용하십시오.

for asset in self.assets { 
    if asset.isVideo == true { 
    asset.fetchAVAsset(.None, completeBlock: { video, info in 

    }) 
    } else { 
    asset.fetchImageWithSize(PHImageManagerMaximumSize, completeBlock: { image, info in 
      if let img = image { 
       // let fixOrientationImage=img.fixOrientation() 

       User.sharedInstance.arrRoomGalleryImages.addObject(img) 
       print("array after selecting images and videos", User.sharedInstance.arrRoomGalleryImages) 

       kAppDelegate.imageSelected = true 
      } 
     }) 
    } 
} 
+0

을 확인? –

+0

을주고있다 –

+0

어떤 구문 오류를주는 구문 오류 –

관련 문제