I am creating an iOS application that is suppose to get the list of images present on the website and display them as tiles on the screen(similar to the displaying of images from photo library). I can display a single image from a URL in UIImageView but when it comes to displaying the complete list of images from a website, i am clueless. Any help in the right direction or any useful tutorial will be appreciated.
Share
There are two parts to this question. I’ll give you a quick response to each one.
1: download a list of images
This could be as straight forward as using +arrayWithContentsOfURL: if you have complete control over your website. Be sure to dispatch the downloading to avoid blocking the UI thread.
NOTE: The URL must return the exact format expected by NSArray and self.images must notify the view that it needs to reload itself ie.
[self.tableView reloadData].If you have less control over the URL, you will need to create a request using something like NSURLRequest, fetch the data using something like NSURLConnection, and parse out the the list of images from the response to create the array of images.
In a much more complex scenario, paging will be involved. This will require only downloading some of the list, then as more images are needed requesting more images then.
2: display the list of images
This could be as simple as using a UITableView with UITableViewCells that use the UITableViewCellStyleDefault style, then set the imageView property in each cell.
To get a better view of the image you could write use a custom table view cell subclassed from UITableViewCell. This would allow you to use a custom placement of the image and set the size of the image to what ever you would like.
In a much more complex senario, you could create your own custom view that contains a UIScrollView that you would place all the images in.