Unable to change image from UIImageView - ios

I have an NSMutableArray with some UIImageView's inside. After a scroll action I want to change the images of some UIImageView but I can't.
This is how I first initiate the Array:
NSMutableArray *dotsImageSliderList = [[NSMutableArray alloc]init];
for (int i=0; i<totalImages; i++)
{
UIImageView *dot =[[UIImageView alloc] initWithFrame:CGRectMake(distance,2,5,5)];
if (i==0)
{
dot.image=[UIImage imageNamed:#"dotselected.png"];
}
else
{
dot.image=[UIImage imageNamed:#"dotunselected.png"];
}
[dotsImageSliderList addObject:dot];
}
And this is how I retrieve the UIImageView's and trying to change the images:
-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
[NSObject cancelPreviousPerformRequestsWithTarget:self];
NSInteger pagenumber = scrollView.contentOffset.x / scrollView.bounds.size.width;
NSLog(#"%zd", pagenumber);
if (pagenumber < [dotsImageSliderList count])
{
for (int i=0; i<[dotsImageSliderList count]; i++)
{
UIImageView *view = [dotsImageSliderList objectAtIndex:pagenumber];
if (i==pagenumber)
{
view.image=[UIImage imageNamed:#"dotselected.png"];
}
else
{
view.image=[UIImage imageNamed:#"dotunselected.png"];
}
}
}
}
I have no idea why the images don't change. Can you spot the mistake?

Initialise image object outside the loop.
NSMutableArray *dotsImageSliderList = [[NSMutableArray alloc]init];
UIImage * selectedImage = [UIImage imageNamed:#"dotselected.png"];
UIImage * unselectedImage = [UIImage imageNamed:#"dotunselected.png"];
for (int i=0; i<totalImages; i++)
{
UIImageView *dot =[[UIImageView alloc] initWithFrame:CGRectMake(distance,2,5,5)];
if (i==0)
{
dot.image=selectedImage;
}
else
{
dot.image=unselectedImage;
}
[dotsImageSliderList addObject:dot];
}

Super silly mistake. I have to change this line:
UIImageView *view = [dotsImageSliderList objectAtIndex:pagenumber];
to this:
UIImageView *view = [dotsImageSliderList objectAtIndex:i];

Related

Apply filter to current image index in UIScrollView GPUImage

Im currently deploying a ImageScroller by UIScrollView, and it contain a filter toolbar at the bottom as you can see on the image.
But im facing a problem is that when i press the button, the filters is only apply to the last image as example below:
Gif Example
So please anyone can help me to solve this one, my expected output is the filter is applied to the current displaying image, not only the last one. Here i would attach my code for your reference and thank you so much.
#interface EditImageVC ()
#end
#implementation EditImageVC
UIImageView *img;
- (void)viewDidLoad {
[super viewDidLoad];
int x=0;
for (int i = 0; i < _scrollViewImageArray.count ; i++) {
_picture = [_scrollViewImageArray objectAtIndex:i];
img =[[UIImageView alloc]initWithFrame:CGRectMake(x,20,[[UIScreen mainScreen] bounds].size.width,
self.imgScrollView.frame.size.height)];
img.image =_picture;
x=x+[[UIScreen mainScreen] bounds].size.width;
[_imgScrollView addSubview:img];
}
_imgScrollView.backgroundColor = [UIColor blackColor];
_imgScrollView.contentSize=CGSizeMake(x,
_imgScrollView.frame.size.height);
_imgScrollView.contentOffset=CGPointMake(0, 0);
img.contentMode = UIViewContentModeScaleAspectFit;
}
-(void)viewDidLayoutSubviews{
self.automaticallyAdjustsScrollViewInsets = NO;
}
- (IBAction)filterAction:(UIButton *)sender {
for (int i = 0; i < _scrollViewImageArray.count ; i++) {
UIImage *picture = [_scrollViewImageArray objectAtIndex:i];
GPUImageFilter *selectedFilter;
switch (sender.tag) {
case 0:
selectedFilter = [[GPUImageSepiaFilter alloc] init];
break;
case 1:
selectedFilter = [[GPUImageToonFilter alloc] init];
break;
default:
break;
}
UIImage *filteredImage = [selectedFilter imageByFilteringImage:picture];
[img setImage:filteredImage];
}
}
Just filter the last shown image and when filter image when scrollview scrolled to another image.
remember to add UIScrollViewDelegate
#interface EditImageVC : UIViewController <UIScrollViewDelegate> {
}
#end
- (void)viewDidLoad {
[super viewDidLoad];
imageViewsArray = [[NSMutableArray alloc] init];
int x=0;
for (int i = 0; i < _scrollViewImageArray.count ; i++) {
_picture = [_scrollViewImageArray objectAtIndex:i];
img =[[UIImageView alloc]initWithFrame:CGRectMake(x,20,[[UIScreen mainScreen] bounds].size.width,
self.imgScrollView.frame.size.height)];
img.image =_picture;
[imageViewsArray addObject:img];
x=x+[[UIScreen mainScreen] bounds].size.width;
[self.imgScrollView addSubview:img];
}
self.imgScrollView.backgroundColor = [UIColor blackColor];
self.imgScrollView.contentSize=CGSizeMake(x,
self.imgScrollView.frame.size.height);
self.imgScrollView.contentOffset=CGPointMake(0, 0);
img.contentMode = UIViewContentModeScaleAspectFit;
self.imgScrollView.delegate = self;
}
GPUImageFilter *selectedFilter = nil;
NSInteger currentShownIndex = 0;
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
NSInteger indexAfterScrolled = scrollView.contentOffset.x / scrollView.frame.size.width;
if(indexAfterScrolled==currentShownIndex) return;
currentShownIndex = indexAfterScrolled;
if(selectedFilter!=nil) {
UIImage *filteredImage = [selectedFilter imageByFilteringImage:[_scrollViewImageArray objectAtIndex:currentShownIndex]];
[[imageViewsArray objectAtIndex:currentShownIndex] setImage:filteredImage];
}
}
- (IBAction)filterAction:(UIButton *)sender {
switch (sender.tag) {
case 0:
selectedFilter = [[GPUImageSepiaFilter alloc] init];
break;
case 1:
selectedFilter = [[GPUImageToonFilter alloc] init];
break;
default:
break;
}
UIImage *picture = [_scrollViewImageArray objectAtIndex:currentShownIndex];
UIImage *filteredImage = [selectedFilter imageByFilteringImage:picture];
[[imageViewsArray objectAtIndex:currentShownIndex] setImage:filteredImage];
}
Updated
If you want to filter current shown image, not need to apply UIScrollViewDelegate:
- (void)viewDidLoad {
[super viewDidLoad];
imageViewsArray = [[NSMutableArray alloc] init];
int x=0;
for (int i = 0; i < _scrollViewImageArray.count ; i++) {
_picture = [_scrollViewImageArray objectAtIndex:i];
img =[[UIImageView alloc]initWithFrame:CGRectMake(x,20,[[UIScreen mainScreen] bounds].size.width,
self.imgScrollView.frame.size.height)];
img.image =_picture;
[imageViewsArray addObject:img];
x=x+[[UIScreen mainScreen] bounds].size.width;
[self.imgScrollView addSubview:img];
}
self.imgScrollView.backgroundColor = [UIColor blackColor];
self.imgScrollView.contentSize=CGSizeMake(x,
self.imgScrollView.frame.size.height);
self.imgScrollView.contentOffset=CGPointMake(0, 0);
img.contentMode = UIViewContentModeScaleAspectFit;
self.imgScrollView.delegate = self;
}
- (IBAction)filterAction:(UIButton *)sender {
NSInteger objectAtIndex:currentShownIndex = scrollView.contentOffset.x / scrollView.frame.size.width;
GPUImageFilter *selectedFilter = nil;
switch (sender.tag) {
case 0:
selectedFilter = [[GPUImageSepiaFilter alloc] init];
break;
case 1:
selectedFilter = [[GPUImageToonFilter alloc] init];
break;
default:
break;
}
UIImage *picture = [_scrollViewImageArray objectAtIndex:currentShownIndex];
UIImage *filteredImage = [selectedFilter imageByFilteringImage:picture];
[[imageViewsArray objectAtIndex:currentShownIndex] setImage:filteredImage];
}

UIScrollView- Image from url did not display

in my project, I have a UITableView view which if I click on the cell it will go to the detail page. In detail page it has a UIScrollView that display an images.
The problem that I'm facing is images from url did not display. It only display placeholder image. But after I click it back to the UITableView view and click on the same cell again. It will display the images from URL.
Here is my code
- (void)loadVisiblePages {
// First, determine which page is currently visible
CGFloat pageWidth = self.scrollView.frame.size.width;
NSInteger page = (NSInteger)floor((self.scrollView.contentOffset.x * 2.0f + pageWidth) / (pageWidth * 2.0f));
// Update the page control
self.pageControl.currentPage = page;
// Work out which pages you want to load
NSInteger firstPage = page - 1;
NSInteger lastPage = page + 1;
// Purge anything before the first page
for (NSInteger i=0; i<firstPage; i++) {
[self purgePage:i];
}
// Load pages in our range
for (NSInteger i=firstPage; i<=lastPage; i++) {
[self loadPage:i];
}
// Purge anything after the last page
for (NSInteger i=lastPage+1; i<self.pageImages.count; i++) {
[self purgePage:i];
}
}
- (void)purgePage:(NSInteger)page {
if (page < 0 || page >= self.pageImages.count) {
// If it's outside the range of what you have to display, then do nothing
return;
}
// Remove a page from the scroll view and reset the container array
UIView *pageView = [self.pageViews objectAtIndex:page];
if ((NSNull*)pageView != [NSNull null]) {
[pageView removeFromSuperview];
[self.pageViews replaceObjectAtIndex:page withObject:[NSNull null]];
}
}
- (void)loadPage:(NSInteger)page {
if (page < 0 || page >= self.pageImages.count) {
// If it's outside the range of what you have to display, then do nothing
return;
}
// 1
UIView *pageView = [self.pageViews objectAtIndex:page];
if ((NSNull*)pageView == [NSNull null]) {
// 2
CGRect frame = self.scrollView.bounds;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0.0f;
self.scrollView.pagingEnabled = YES;
// 3
UIImageView *newPageView = [[UIImageView alloc] initWithImage:[self.pageImages objectAtIndex:page]];
//Fit the Screen
//newPageView.contentMode = UIViewContentModeScaleToFill;
newPageView.contentMode = UIViewContentModeScaleAspectFit;
newPageView.frame = frame;
newPageView.userInteractionEnabled = YES;
[self.scrollView addSubview:newPageView];
// 4
[self.pageViews replaceObjectAtIndex:page withObject:newPageView];
UITapGestureRecognizer *SingleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:#selector(actionHandleTapOnImageView:)];
[SingleTap setNumberOfTapsRequired:1];
[newPageView addGestureRecognizer:SingleTap];
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
// Load the pages that are now on screen
[self loadVisiblePages];
}
- (void)viewDidLoad {
[super viewDidLoad]
// Add image into slide image
if([data.gallery count] == 1){
_imageView1 = [[UIImageView alloc] init];
[_imageView1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"%#", data.gallery[0]]]placeholderImage:[UIImage imageNamed:#"placeholder.png"]];
self.pageImages = [[NSMutableArray alloc] initWithObjects:_imageView1.image, nil];
}else if([data.gallery count] == 2){
// Load image from server
_imageView1 = [[UIImageView alloc] init];
[_imageView1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"%#", data.gallery[0]]]placeholderImage:[UIImage imageNamed:#"placeholder.png"]];
self.pageImages = [[NSMutableArray alloc] initWithObjects:_imageView1.image, nil];
_imageView2 = [[UIImageView alloc] init];
[_imageView2 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"%#", data.gallery[1]]]placeholderImage:[UIImage imageNamed:#"placeholder.png"]];
// Add image to page
self.pageImages = [[NSMutableArray alloc] initWithObjects:_imageView1.image,_imageView2.image, nil];
}
}
NSInteger pageCount = self.pageImages.count;
// 2
self.pageControl.currentPage = 0;
self.pageControl.numberOfPages = pageCount;
// 3
self.pageViews = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i < pageCount; ++i) {
[self.pageViews addObject:[NSNull null]];
}
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// 4
CGSize pagesScrollViewSize = self.scrollView.frame.size;
self.scrollView.contentSize = CGSizeMake(pagesScrollViewSize.width * self.pageImages.count, pagesScrollViewSize.height);
// 5
[self loadVisiblePages];
}

unable to create multiple UIImageView in loop ios

I am trying to show no. of images in different image view. if i have 3 image then i want show in 3 diff. UIImageView in my View. Here is my code that only shows one image. What have i missed here?
NSArray * _thumbnails = _claimReport.photos.allObjects;
if (_thumbnails.count >0)
{
NSMutableArray *imageViews = [[NSMutableArray alloc] init];
for (int i =1; i<_thumbnails.count; i++)
{
UIImageView *newImageViews = [[UIImageView alloc]initWithFrame:CGRectMake(40, 1700*i+20, 670, 700)];
LAPhoto *photo = [_thumbnails objectAtIndex:i];
[newImageViews setImage:[UIImage imageWithData:photo.photo]];
NSLog(#" newImageViews %# ",newImageViews);
[imageViews addObject:newImageViews];
[self.formView addSubview:newImageViews];
}
NSLog(#"Count %d" , imageViews.count);
}
You can add the images in a scroll view:
self.scrollView = [[UIScrollView alloc]initWithFrame:self.view.bounds];
[self.formView addSubview:self.scrollView];
NSArray * _thumbnails = _claimReport.photos.allObjects;
if (_thumbnails.count >0)
{
NSMutableArray *imageViews = [[NSMutableArray alloc] init];
for (int i =0; i<_thumbnails.count; i++)
{
UIImageView *newImageViews = [[UIImageView alloc]initWithFrame:CGRectMake(40, 800*i+20, 670, 700)];
LAPhoto *photo = [_thumbnails objectAtIndex:i];
[newImageViews setImage:[UIImage imageWithData:photo.photo]];
NSLog(#" newImageViews %# ",newImageViews);
[imageViews addObject:newImageViews];
self.scrollView.contentSize = CGSizeMake(670, 800 *i + 800);
[self.scrollView addSubview:newImageViews];
}
NSLog(#"Count %d" , imageViews.count);
}

showing four random images

I am using this code to generate random image to UIImageView. When I click the button, it apears another image. I would like to ask you how to create four imageviews - click button -> apears four different random images.
ViewController.h
#interface ViewController : UIViewController {
IBOutlet UIImageView *imageView;
// IBOutlet UIImageView *imageView2;
}
-(IBAction) randomImage;
ViewController.m
- (IBAction) randomImage {
NSArray *images = [[NSArray alloc] initWithObjects:#"image1.jpg", #"image2.jpg", #"image3.jpg", #"image4.jpg", nil];
int count = [images count]
int index = arc4random() % count;
imageView.image = [UIImage imageNamed:[images objectAtIndex:index]];
// imageView2.image = ....
}
I created four imageViews in storyboard and I was trying something like above // imageView2.image... but it it not the right solution :-)
Thank you for your help
Code to list 4 random image:
NSMutableArray *images = [[NSMutableArray alloc] initWithArray: #[#"image1.jpg", #"image2.jpg", #"image3.jpg", #"image4.jpg"]];
int countImg = images.count;
for (int i = 0; i < countImg; i++) {
NSInteger index = arc4random() % images.count;
NSLog(#"Image%d name = %#",i , [images objectAtIndex:index]);
[images removeObjectAtIndex:index];
}
Rather than using IBOutlet UIImageView *imageView;, use IBOutletCollection(UIImageView) NSArray *imageViews; and connect all of your image views to this.
Then, in your code:
- (IBAction) randomImage {
NSArray *images = [[NSArray alloc] initWithObjects:#"image1.jpg", #"image2.jpg", #"image3.jpg", #"image4.jpg", nil];
NSInteger count = [images count];
for (UIImageView *imageView in self.imageViews) {
NSInteger index = arc4random() % count;
imageView.image = [UIImage imageNamed:[images objectAtIndex:index]];
}
}

Parsing JSON images in a background thread (AFNetworking)

I have an image slideshow with images that are being parsed with JSON and I want to run that slideshow in a background thread.
My original code:
- (void)loadVisiblePages {
// First, determine which page is currently visible
CGFloat pageWidth = self.scrollView.frame.size.width;
NSInteger page = (NSInteger)floor((self.scrollView.contentOffset.x * 2.0f + pageWidth) / (pageWidth * 2.0f));
// Update the page control
self.pageControl.currentPage = page;
// Work out which pages we want to load
NSInteger firstPage = page - 1;
NSInteger lastPage = page + 1;
// Purge anything before the first page
for (NSInteger i=0; i<firstPage; i++) {
[self purgePage:i];
}
for (NSInteger i=firstPage; i<=lastPage; i++) {
[self loadPage:i];
}
for (NSInteger i=lastPage+1; i<self.pageImages.count; i++) {
[self purgePage:i];
}
}
- (void)loadPage:(NSInteger)page {
if (page < 0 || page >= self.pageImages.count) {
// If it's outside the range of what we have to display, then do nothing
return;
}
// Load an individual page, first seeing if we've already loaded it
UIView *pageView = [self.pageViews objectAtIndex:page];
if ((NSNull*)pageView == [NSNull null]) {
CGRect frame = self.scrollView.bounds;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0.0f;
UIImageView *newPageView = [[UIImageView alloc] initWithImage:[self.pageImages objectAtIndex:page]];
newPageView.contentMode = UIViewContentModeScaleAspectFit;
newPageView.frame = frame;
[self.scrollView addSubview:newPageView];
[self.pageViews replaceObjectAtIndex:page withObject:newPageView];
}
}
- (void)purgePage:(NSInteger)page {
if (page < 0 || page >= self.pageImages.count) {
// If it's outside the range of what we have to display, then do nothing
return;
}
// Remove a page from the scroll view and reset the container array
UIView *pageView = [self.pageViews objectAtIndex:page];
if ((NSNull*)pageView != [NSNull null]) {
[pageView removeFromSuperview];
[self.pageViews replaceObjectAtIndex:page withObject:[NSNull null]];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray *images = _singleRelease[#"images"];
NSMutableArray *mediumImages = [NSMutableArray array];
for (NSDictionary *imageDictionary in images){
NSURL *imageURL = [NSURL URLWithString:imageDictionary[#"image_file"][#"image_file"][#"medium"][#"url"]];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *image = [UIImage imageWithData:imageData];
[mediumImages addObject:image];
}
self.pageImages = [mediumImages copy];
NSInteger pageCount = self.pageImages.count;
self.pageControl.currentPage = 0;
self.pageControl.numberOfPages = pageCount;
self.pageViews = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i < pageCount; ++i) {
[self.pageViews addObject:[NSNull null]];
}
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// 4
CGSize pagesScrollViewSize = self.scrollView.frame.size;
self.scrollView.contentSize = CGSizeMake(pagesScrollViewSize.width * self.pageImages.count, pagesScrollViewSize.height);
// 5
[self loadVisiblePages];
}
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
// Load the pages which are now on screen
[self loadVisiblePages];
}
I tried customizing a code sample I found online, but I cant get it to work with my code.
This is what I have so far:
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray *images = _singleRelease[#"images"];
NSMutableArray *mediumImages = [NSMutableArray array];
dispatch_queue_t imageQueue = dispatch_queue_create("Image Queue",NULL);
for (NSDictionary *imageDictionary in images){
dispatch_async(imageQueue, ^{
NSURL *imageURL = [NSURL URLWithString:imageDictionary[#"image_file"][#"image_file"][#"medium"][#"url"]];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *image = [UIImage imageWithData:imageData];
[mediumImages addObject:image];
dispatch_async(dispatch_get_main_queue(), ^{
NSInteger pageCount = self.pageImages.count;
self.pageImages = [mediumImages copy];
self.pageControl.currentPage = 0;
self.pageControl.numberOfPages = pageCount;
self.pageViews = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i < pageCount; ++i) {
[self.pageViews addObject:[NSNull null]];
}
});
});
}
}
This was another code sample I tried customizing but I get the same outcome.
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray *images = [self.singleRelease[#"images"] copy];
__weak __typeof__(self) weakself = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSMutableArray *mediumImages = [NSMutableArray array];
for (NSDictionary *imageDictionary in images){
NSURL *imageURL = [NSURL URLWithString:imageDictionary[#"image_file"][#"image_file"][#"medium"][#"url"]];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *image = [UIImage imageWithData:imageData];
if (image) {
[mediumImages addObject:image];
}
}
dispatch_sync(dispatch_get_main_queue(), ^{
if (weakself) {
__typeof__(self) weakself = weakself;
self.pageImages = mediumImages;
NSInteger pageCount = self.pageImages.count;
self.pageControl.currentPage = 0;
self.pageControl.numberOfPages = pageCount;
self.pageViews = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i < pageCount; ++i) {
[self.pageViews addObject:[NSNull null]];
}
};
});
});
}
Both codes load my Page Control with the correct number of slides, but the images don't appear.
Any help? Thanks.
Fixed it.
Delete viewWillAppear and then replace the current viewDidLoad with this:
/**
* Called after the controller’s view is loaded into memory.
*/
- (void)viewDidLoad
{
[super viewDidLoad];
self.release_name.text = [self.singleRelease objectForKey:#"release_name"];
if ([_singleRelease objectForKey:#"release_price"])
self.release_price.text = [NSString stringWithFormat:#"$%#",[_singleRelease objectForKey:#"release_price"]];
self.release_colorway.text = [self.singleRelease objectForKey:#"release_colorway"];
if([_singleRelease objectForKey:#"release_date"] != NULL)
{
NSString *readableDate = [_singleRelease objectForKey:#"release_date"]; // I assume that this is a string
UpcomingRelease *upcoming = [[UpcomingRelease alloc] init];
upcoming.release_date = readableDate;
self.release_date.text = [NSString stringWithFormat:#"%#", upcoming.formattedDate];
}
NSArray *images = self.singleRelease[#"images"];
// we get the image on a background queue
dispatch_queue_t imageQueue = dispatch_queue_create("Image Queue",NULL);
dispatch_async(imageQueue,
^{
NSMutableArray *mediumImages = [[NSMutableArray alloc] initWithCapacity:images.count];
// for each image url we get the image and add it to the array
for (NSDictionary *imageDictionary in images)
{
NSURL *imageURL = [[NSURL alloc] initWithString:imageDictionary[#"image_file"][#"image_file"][#"medium"][#"url"]];
NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageURL];
UIImage *image = [[UIImage alloc] initWithData:imageData];
[mediumImages addObject:image];
}
// once we have obtained all of the images we use them
dispatch_async(dispatch_get_main_queue(),
^{
// we get a strong pointer to the images array and set the pages count according to how many there are
self.pageImages = [mediumImages copy];
NSInteger pageCount = self.pageImages.count;
// we set the page control appropriate for the number of images that need to be presented
self.pageControl.currentPage = 0;
self.pageControl.numberOfPages = pageCount;
// we then make mock page views
self.pageViews = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i < pageCount; ++i)
{
[self.pageViews addObject:[NSNull null]];
}
// once we have the images we load the pages with them
CGSize pagesScrollViewSize = self.scrollView.frame.size;
self.scrollView.contentSize = CGSizeMake(pagesScrollViewSize.width * self.pageImages.count, pagesScrollViewSize.height);
[self loadVisiblePages];
});
});
_scrollView.showsHorizontalScrollIndicator=NO;
_scrollView.showsVerticalScrollIndicator=NO;
}
The problem was you were trying to load the pages before the images had finished fetching.

Resources