How to Load Big Image From URL Without Freezing App In IOS Using Swift 2.0

Inwizards-blog-img

If you want to load big image from URL so you can use AFNetworking Library into your Project, so with the help of this library you can load big image from url without freezing your app.
First download AFNetworking Library from GitHub by click on this link
https://github.com/AFNetworking/AFNetworking
after download unzip and and add to your project
1. now import AFNetworking.h file into your YourProject-Bridging-Header.h file
and now create object of AFHTTPRequestOperation

Source Code:

let UrlString:NSString = “Your Image URL”

let ImageURL:NSURL = NSURL(string: UrlString:NSString as String)!

let URLRequest:NSURLRequest = NSURLRequest(URL: ImageURL)

let requestOperation:AFHTTPRequestOperation = AFHTTPRequestOperation(request: URLRequest)

requestOperation.responseSerializer = AFHTTPResponseSerializer()



requestOperation.setCompletionBlockWithSuccess({ (operation:AFHTTPRequestOperation, data:AnyObject) -> Void in

yourImageView.image = UIImage(data: data as! NSData)

}, failure: { (operation:AFHTTPRequestOperation?, error:NSError) -> Void in

yourImageView.image = UIImage(named: “default.png”)

})

requestOperation.start()

)

How to Load Big Image From URL Without Freezing App In IOS Using Swift 2.0

Post navigation


0 0 vote
Article Rating
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
GuestSnirm
GuestSnirm
6 years ago

guest test post

Jordan Older
Jordan Older
5 years ago

I have learn several excellent stuff here. Definitely worth bookmarking for revisiting.
I surprise how so much attempt you put to create such a excellent
informative website.

2
0
Would love your thoughts, please comment.x
()
x