alamofireimage

Using AlamofireImage Inside UITableViewCell

泪湿孤枕 提交于 2019-12-10 12:45:10
问题 I've been reading a lot of answers here saying that by using AlamofireImage helper methods (e.g. af_setImageWithURL() ) or any equivalent library, you don't need to worry about cell reusing stuff (Plus, many published tutorials actually just do that). That is to say, I don't have to keep a weak reference to the cell or getting it by using tableView's cellForRowAtIndexPath() method to update its imageView after the background downloading finishes, like what we usually do if request made

AlamofireImage Disk Cache not working

北城余情 提交于 2019-12-09 17:34:58
问题 I want to use AlamofireImage to download images from an url and then cache it on the device disk space. I read several posts about this and found out that AlamofireImage supports this with the help of the ImageDownloader class. The most interesting information was given in this SO answer So I tried to set a custom NSURLCache for the ImageDownloader so that it would cache the images directly to the disk. I did that by setting the memory capacity to 0. Then I use this custom ImageDownloader to

iOS Swift: How to properly scale down an image?

ぐ巨炮叔叔 提交于 2019-12-09 01:36:23
问题 I'm using AlamofireImage to download and set my UIImage: backdrop.af_setImageWithURL(downloadURL) The image is substantially larger than what I will be displaying and so I have an issue with aliasing. How can I resize this image properly? Results: 回答1: You can resize the image with any size once you have a valid UIImage : func resizedImageWith(image: UIImage, targetSize: CGSize) -> UIImage { let imageSize = image.size let newWidth = targetSize.width / image.size.width let newHeight =

Swift 4 AlamofireImage with UITableView Cell

别等时光非礼了梦想. 提交于 2019-12-05 01:37:39
I am using AlamofireImages to try to download an image from a server and display it in my table view cell, this is what I got, but my images does not appear, just the textLabel and detailTextLabel override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "trendingCell", for: indexPath) print(self.array[indexPath.row]) cell.textLabel?.text = (self.array[indexPath.row]["title"] as! String) cell.detailTextLabel?.text = (self.array[indexPath.row]["username"] as! String) Alamofire.request("http:

AlamofireImage Disk Cache not working

柔情痞子 提交于 2019-12-04 04:15:42
I want to use AlamofireImage to download images from an url and then cache it on the device disk space. I read several posts about this and found out that AlamofireImage supports this with the help of the ImageDownloader class. The most interesting information was given in this SO answer So I tried to set a custom NSURLCache for the ImageDownloader so that it would cache the images directly to the disk. I did that by setting the memory capacity to 0. Then I use this custom ImageDownloader to download an image. The folder that I specified for the disk path is created on the disk but

Alamofire4 migration, Apple Mach-O Linker (id) Error

时光总嘲笑我的痴心妄想 提交于 2019-12-02 22:11:50
问题 After spending weeks migrating all my Alamofire code to AF4/Swift3, I finally fixed all the complier errors due to Alamofire Function changes, but now when I try to build a I get a whole bunch of these Apple Mach-O errors. There's at least 29 of them and they all have either Alamofire or AlamofireImage in them (aside from the last one which is "Linker command failed with exit code 1"). I don't have a clue of what to do here, I'll post any extra info needed, can anyone help me out here? edit:

Alamofire4 migration, Apple Mach-O Linker (id) Error

给你一囗甜甜゛ 提交于 2019-12-02 07:50:31
After spending weeks migrating all my Alamofire code to AF4/Swift3, I finally fixed all the complier errors due to Alamofire Function changes, but now when I try to build a I get a whole bunch of these Apple Mach-O errors. There's at least 29 of them and they all have either Alamofire or AlamofireImage in them (aside from the last one which is "Linker command failed with exit code 1"). I don't have a clue of what to do here, I'll post any extra info needed, can anyone help me out here? edit: Here are the first 3 errors, I copied only the parts highlighted in red. I will post the full log if

iOS Swift: How to properly scale down an image?

妖精的绣舞 提交于 2019-12-01 01:04:14
I'm using AlamofireImage to download and set my UIImage: backdrop.af_setImageWithURL(downloadURL) The image is substantially larger than what I will be displaying and so I have an issue with aliasing. How can I resize this image properly? Results: You can resize the image with any size once you have a valid UIImage : func resizedImageWith(image: UIImage, targetSize: CGSize) -> UIImage { let imageSize = image.size let newWidth = targetSize.width / image.size.width let newHeight = targetSize.height / image.size.height var newSize: CGSize if(newWidth > newHeight) { newSize = CGSizeMake(imageSize

Upload Photo / File with JSON and custom headers via Swift 3 and Alamofire 4 | iOS | Swift

南笙酒味 提交于 2019-11-30 14:04:13
问题 I need to call the Multipart request with Image file and JSON. I have tried this, but still getting the error. // define parameters let parameters = [ "hometown": "yalikavak", "living": "istanbul" ] Alamofire.upload(multipartFormData: { multipartFormData in if let imageData = UIImageJPEGRepresentation(image, 1) { multipartFormData.append(imageData, withName: "file", fileName: "file.png", mimeType: "image/png") } for (key, value) in parameters { multipartFormData.append((value?.data(using:

Download File Using Alamofire 4.0 (Swift 3)

Deadly 提交于 2019-11-30 06:34:12
In older version of Alamofire. This is how I download file let destinationPath = Alamofire.Request.suggestedDownloadDestination( directory: .documentDirectory, domain: .userDomainMask); Alamofire.download(.GET, urlString, destination: destinationPath) .progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in // print(totalBytesRead) } .response { request, response, _, error in let downloadedFilePath = destinationPath(URL(string: "")!, response!); NSUserDefaultsHelper.saveURL(downloadedFilePath, key: urlString); completion(downloadedFilePath, true); } But now in the new version, my