Swift 구현 객체 클래스 = = 재로드 및 iOS 포토 앨범 및 카메라 이미지 선택 문제

1690 단어
    var type: ModelType?
    var data: PHAsset?
   init(type: ModelType?,data:PHAsset?){
        self.type = type
        self.data = data
    }
      static func ==(lhs: customModel, rhs: customModel) -> Bool {
        return lhs.type == rhs.type && lhs.data == rhs.data
   }}```
  Equatable 
 ,for   , ,   
  ```  for  model in  selectModel{
            if  model == newmodel{
                return
           }
       selectModel.insert(newmodel, at: 0)
}```
 
``` func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
       let   img  = info[ UIImagePickerControllerOriginalImage] as!  UIImage       
       PHPhotoLibrary.shared().performChanges({
        let   req = PHAssetChangeRequest.creationRequestForAsset(from: img)  self.cameraidentitifer.append((req.placeholderForCreatedAsset?.localIdentifier)
       }) { (success, err) in
        if success {
            //     
            DispatchQueue.main.async {
                self.updateCameraimgs()
            }
        }
       }
        //      cell 
        dismiss(animated: true, completion: nil)
    }```

// localindentity 
```  if  self.cameraidentitifer.count == 0 {
            return
        }
        let   fetchresult = PHAsset.fetchAssets(withLocalIdentifiers: self.cameraidentitifer, options: nil)
  fetchresult.enumerateObjects({ (assert,pos, stop) in
            var  phasets = [PHAsset]()
            phasets.append(assert)
  //     
            DispatchQueue.main.async {
                self.onImageSelectFinished(images: phasets)
                self.cameraidentitifer.removeAll()
            }
        })```

좋은 웹페이지 즐겨찾기