Comments (7)
Use fetchFullScreenImageWithCompleteBlock...
like this:
assets.first?.fetchFullScreenImageWithCompleteBlock({ image, info in
let object = CustomObject()
object.image = image
})
from dkimagepickercontroller.
and how to make all photos in DKAsset to new class?
from dkimagepickercontroller.
Maybe I should provide a sync method to fetch an image..
from dkimagepickercontroller.
yeah that would be great, anyway im using this code
for asset in photos{
asset.fetchFullScreenImageWithCompleteBlock({ image, info in
let images = image
let data1 = dataImage(userId: "1", value: 1.0, photo: images)
self.datas += [data1]
print("*")
})
}
print("datas: \(datas.count)")
i have 6 'image' in photos(DKAsset) and '*' print 6 times, but datas.count is 0, do you have any guess what did i missed?
from dkimagepickercontroller.
Try this:
let options = PHImageRequestOptions()
options.deliveryMode = .HighQualityFormat
options.resizeMode = .Exact;
options.synchronous = true
for asset in photos {
asset.fetchImageWithSize(UIScreen.mainScreen().bounds.size.toPixel(), options: options,
completeBlock: { image, info in
let images = image
let data1 = dataImage(userId: "1", value: 1.0, photo: images)
self.datas += [data1]
print("*")
})
}
print("datas: \(datas.count)")
from dkimagepickercontroller.
I just found the answer of this problem, turns out it prints 0 because loop finishes very quickly, while all 6 asset fetches occur in the background. http://stackoverflow.com/questions/34890905/failed-to-input-data-to-class-model-swift/34891231#34891231.
Anyway thank you for the great lib and fast answers bro!
from dkimagepickercontroller.
Yes, the fetches
method executed in the background. So you can specific the synchronous
of the PHImageRequestOptions
to true
like my above answer :)
And I've added two functions to sync fetch images in 3.0.6:
/**
Fetch an image with the current screen size.
- parameter sync: If true, the method blocks the calling thread until image is ready or an error occurs.
- parameter completeBlock: The block is executed when the image download is complete.
*/
public func fetchFullScreenImage(sync: Bool, completeBlock: (image: UIImage?, info: [NSObject : AnyObject]?) -> Void)
/**
Fetch an image with the original size.
- parameter sync: If true, the method blocks the calling thread until image is ready or an error occurs.
- parameter completeBlock: The block is executed when the image download is complete.
*/
public func fetchOriginalImage(sync: Bool, completeBlock: (image: UIImage?, info: [NSObject : AnyObject]?) -> Void)
Anyway please let me know if you have any questions :)
from dkimagepickercontroller.
Related Issues (20)
- Xcode 13.3 - Error (Xcode): Segmentation fault: 11 Encountered error while archiving for device. HOT 35
- Crash on DKCamera.captureImage function HOT 1
- How to get original files URLs?
- Xcode 14: Swift Compiler Error: Stored properties cannot be marked potentially unavailable with '@available' HOT 4
- ios error Signing for "DKImagePickerController-DKImagePickerController" requires a development team. HOT 14
- After changing to 4.3.4, Now i cant compile with BITCODE enabled HOT 4
- XCode 14 Build error: Stored properties cannot be marked potentially unavailable with '@available' HOT 16
- I want to export the video to .mp4
- xcode14中不兼容ios12系统
- No Actions when clicking in Camera Icon, it should open camera to capture
- How to perform Multiple Image selection but only single video selection
- Xcode 13 升级 14后,运行到真机没有问题但是打包会报错 HOT 4
- Error output from CocoaPods:
- Add tag 4.3.5 or higher to enable Swift Package Manager versioning support HOT 1
- Add tags to dependend packages in order to be able to fetch DKImagePickerController with a versioned rule
- Library not loaded: @rpath/DKImagePickerController.framework/DKImagePickerController HOT 2
- Support App Privacy Manifests HOT 5
- Version 4.3.7 is failing with TOCropViewController HOT 1
- Privacy Manifest is missing an entry HOT 1
- Crashed: DKCamera/DKCamera.swift:1154: Fatal error: Unexpectedly found nil while unwrapping an Optional value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dkimagepickercontroller.