我的應用程序崩潰,錯誤線程1:EXC_BAD_INSTRUCTION當這種方法被稱爲:應用程序崩潰時,我打電話requestImage
imageManager.requestImage(for: asset!, targetSize: CGSize(width:100,height:100), contentMode: .aspectFit, options: options, resultHandler: {(image,info) -> Void in})
在查看完整的代碼做負載:
override func viewDidLoad() {
super.viewDidLoad()
collectionView.delegate = self;
collectionView.dataSource = self;
let fetchResult = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: nil);
let asset = fetchResult.firstObject;
let options = PHImageRequestOptions()
options.deliveryMode = .fastFormat
options.isSynchronous = true
let imageManager = PHCachingImageManager();
imageManager.requestImage(for: asset!, targetSize: CGSize(width:100,height:100), contentMode: .aspectFit, options: options, resultHandler: {(image,info) -> Void in
print("Got image")
})
}
任何人都知道可能是什麼導致錯誤?我認爲這是與封閉,但我不知道什麼是錯的...
這裏是我試圖調用該方法的語法:
func requestImage(for asset: PHAsset, targetSize: CGSize, contentMode: PHImageContentMode, options: PHImageRequestOptions?, resultHandler: (UIImage?, [NSObject : AnyObject]?) -> Void) -> PHImageRequestID
謝謝!