Reputation: 677
I was tasked to create a image viewer just like IKEA's catalogue viewer. It's completely out of my skills but after all I must try it. I was once able to create photo viewer with UIScrollView like iPhone's Photo App, but IKEA's catalogue app is far more complicated as it has different parts per catalogue (title page, spread pages, back cover page). It cannot be done by my photo viewer code since it only requires simple array of UIImages. I have to separate them in several parts.
To achieve that, first I have to look for the way to put two UIImages into one UIScrollView, to make those two pages as one spread (two facing pages) zoomable UIScrollView. And our "web service" provides just an array of pages...
Is there any way to achieve this? I have searched around but all of them are the case about "marging" two UIImages, not putting them side by side as one UIImage. Should I have to create one UIImage from two UIImages then put it to the UIScrollView?
I know it's rather simple and noob question, but I really don't know where to start.
Any help would be appreciated.
Upvotes: 0
Views: 154
Reputation: 1752
If you want to make photo viewer then you should read SDWebImage. This will cache UIIamge with lazy loading. Use its sample code. It will help you a lot.
Upvotes: 1
Reputation: 33471
To nest UIImages in the UIScrollView, you should create 2 UIImageViews, figure out the frame dimensions you need, then call [self.scrollView addSubview:myImageView];
for each UIImageView. For example:
UIImage *image1 = [UIImage imageNamed:@"image1"];
UIImage *image2 = [UIImage imageNamed:@"image2"];
UIImageView *imageView1 = [[UIImageView alloc] initWithImage:image1];
// put your specific frame values here
imageView1.frame = CGRectMake(100.0f,100.0f,200.0f,200.0f);
UIImageView *imageView2 = [[UIImageView alloc] initWithImage:image2];
// put your specific frame values here
imageView2.frame = CGRectMake(300.0f,100.0f,200.0f,200.0f);
// This is a property tied to your scrollView, either created in code or in Interface Builder
[self.scrollView addSubview:imageView1];
[self.scrollView addSubview:imageView2];
Upvotes: 0