iOS
कैश ऑनलाइन छवियों
खोज…
AlamofireImage
AlamofireImage का उपयोग करके ऑनलाइन छवियां कैशिंग करें। यह स्विफ्ट में Alamofire शीर्ष पर काम करता है। AlamofireImage का उपयोग करके cocoapods स्थापित करें
pod 'AlamofireImage', '~> 3.1'
सेट अप:
- आयात
AlamofireImageऔरAlamofire - छवि कैश सेट करें: छवि को कैश करें
let imageCache = AutoPurgingImageCache( memoryCapacity: 111_111_111, preferredMemoryUsageAfterPurge: 90_000_000) - एक अनुरोध करना और Cache में चित्र जोड़ना:
Alamofire.request(self.nameUrl[i]).responseImage { response in
if response.result.value != nil {
let image = UIImage(data: response.data!, scale: 1.0)!
imageCache.add(image, withIdentifier: self.nameUrl[i])
}
}
- कैश से छवियाँ प्राप्त करें:
if let image = imageCache.image(withIdentifier: self.nameUrl[self.a])
{
self.localImageView.image = image
}
अधिक जानकारी के लिए इस लिंक का अनुसरण करें
Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow