How to convert an PFFile to an UIImage with swift?
PFFile is a parse representation of anykind of file. To get the "real" file (image), you need to call getDataInBackgroundWithBlock
. Try it:
if let userPicture = object.valueForKey("Image")! as! PFFile {
userPicture.getDataInBackgroundWithBlock({
(imageData: NSData!, error NSError!) -> Void in
if (error == nil) {
let image = UIImage(data:imageData)
self.ImageArray.append(image)
}
})
}
Converting PFFile to UIImage
I am doubtful that the class of the ImageView is UIImageView and not PFImageView...
Select your imageView and go to identity inspector, it must be appearing like this...
Should be this...
As it is PFImageView that understands the getter and setter methods for property 'file'.
PFFile to UIImage with swift 3?
I Solved my problem
Swift 3 :
if let userPicture = object.valueForKey("Image")! as! PFFile {
userPicture.getDataInBackground({ (imageData: Data?, error: Error?) -> Void in
let image = UIImage(data: imageData!)
if image != nil {
self.imageArray.append(image!)
}
})
}
PFFile as UIImageView
I ended up solving this issue. I made my custom cell a PFTableViewCell and turned the image into a PFImageView. I then used the following code, which works around converting the PFFile into a UIImage because PFImageView can accept a PFFile. This makes the downloading of the PFFile from Parse a lot smoother.
cell.scorecardCellImage.file = scorecardData[indexPath.row].scorecardImage
cell.scorecardCellImage.loadInBackground()
CIImage Convert to UIImage
you will call init for resolve this issue
imgurl.image = UIImage.init(ciImage: transformedImage)
Related Topics
Search Bar and Search Display Controller in Table View
Adding Unlimited Lines in a Text (Swiftui)
Passing Data Back from a Modal View in Watchkit
iOS Autolayout and Uitoolbar/Uibarbuttonitems
How to Connect Multiple Buttons in a Storyboard to a Single Action
How to Parse Iso 8601 Using Nsdateformatter with Optional Milliseconds Part
Swift: Random Number for 64-Bit Integers
How to Pass Data from Child to Parent View Controller? in Swift
iOS Swift: How to Change the Font Style of a Certain Word in a String
App Updates, Nsurl, and Documents Directory
Location Access - App Is Not Asking for User Permission to Access Location - iOS 11
Get Dns Server Ip from iPhone Settings
Region Monitoring Glitch on iOS 7 - Multiple Notifications at the Same Time
iOS Check If Application Has Access to Microphone
Add a Child View Controller's View to a Subview of the Parent View Controller
Changing Uitableview's Section Header/Footer Title Without Reloading the Whole Table View