Objective-C: Getting UIActivity indicators for images in UITableView - objective-c

I was wondering if anyone knew the best way of getting in a UITableView, where we have images on the left hand side, for the images to appear with UIActivity indicator gradually rather than not being there and appearing all of a sudden. Ive seen that on a few apps and wanted to know how to do it.

I haven't done this myself, but my idea would be to create my own UIView subclass that handles showing the UIActivity indicator while the image is loading. Then add instances of that view to your table cells instead of plain UIImageViews.
Update:
OK, as I said before, I haven't done this myself. The following is just typed into the browser, and I'm not sure if you'd run into any issues with threading, but it should give you an idea as to how to approach this:
#interface IndicatorImageView : UIView {
UIImageView *imageView;
UIActivityIndicatorView *indicator;
NSString *imageName;
NSURL *imageURL;
}
#property (nonatomic, copy) NSString *imageName;
#property (nonatomic, retain) NSURL* imageURL;
#end
#implementation IndicatorImageView
#synthesize imageName;
#synthesize imageURL;
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
imageView = [[UIImageView alloc] initWithFrame:self.bounds];
[self addSubview:imageView];
indicator = [[UIActivityIndicatorView alloc] initWithFrame:self.bounds];
[self addSubview:indicator];
}
return self;
}
- (void)setImageName:(NSString *)anImageName {
if (imageName == anImageName) {
return;
}
[imageName release];
imageName = [anImageName copy];
// optionally remove the old image while we're updating
//imageView.image = nil;
[indicator startAnimating];
[self performSelectorInBackground:#selector(updateImageViewUsingImageName) withObject:nil];
}
- (void)setImageURL:(NSURL *)anImageURL {
if (imageURL == anImageURL) {
return;
}
[imageURL release];
imageURL = [anImageURL copy];
// optionally remove the old image while we're updating
//imageView.image = nil;
[indicator startAnimating];
[self performSelectorInBackground:#selector(updateImageViewUsingImageURL) withObject:nil];
}
- (void)updateImageViewUsingImageName {
NSAutoreleasepool *pool = [[NSAutoreleasePool alloc] init];
imageView.image = [UIImage imageNamed:imageName];
[indicator performSelectorOnMainThread:#selector(stopAnimating) withObject:nil];
[pool release];
}
- (void)updateImageViewUsingImageURL {
NSAutoreleasepool *pool = [[NSAutoreleasePool alloc] init];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
imageView.image = [UIImage imageWithData:imageData];
[indicator performSelectorOnMainThread:#selector(stopAnimating) withObject:nil];
[pool release];
}
#end
When you set the imageName property, the image will be loaded in the background while the UIActivityIndicatorView is animating. Once the image is loaded and set on the UIImageView, we stop animating the activity indicator.

If I can remember correctly something like that was shown in stanford lectures cs193, iPhone Application Programming, when loading profile pictures from twitter accounts.
Have a look for the appropriate presentation (I can't remember which one it was), look at notes that talk about table view then have a look at itunesu video of the lecture.
http://www.stanford.edu/class/cs193p/cgi-bin/index.php

Subclass UIImage and add the UIActivityIndicator as a subview. Add some methods to the class for setting the image source, and start/stop the UIActivityIndicator appropriately.

Related

AVCaptureVideoPreviewLayer not showing

The goal is to simply display live video input from the webcam.
The code is distilled from one of Apple's examples and it seems to be at least partially working since the led next to the camera lights up when running.
I ctrl-dragged from the view in the storyboard to the outlet property in the interface and it is connected as referencing outlet now but nothing shows up, not even the black background color is set.
Any idea where I'm going wrong?
Thanks for your help
Edit:
Actually it is working just as expected if I set a breakpoint at the [previewViewLayer addSublayer:self.previewLayer]; line and continue to run in the debugger. There has to be some kind of timing issue.
Interface:
#property (retain) AVCaptureDevice *videoDevice;
#property (retain) AVCaptureDeviceInput *videoDeviceInput;
#property (retain) AVCaptureSession *session;
#property (retain) AVCaptureVideoPreviewLayer *previewLayer;
#property (assign) IBOutlet NSView *previewView;
Implementation:
- (void)viewDidLoad {
[super viewDidLoad];
[self getDevice];
[self initSession];
}
- (void)initSession {
// Create a capture session
// self.session = [[AVCaptureSession alloc] init];
[self setSession:[[AVCaptureSession alloc] init]];
// Attach preview to session
CALayer *previewViewLayer = [self.previewView layer];
[previewViewLayer setBackgroundColor:CGColorGetConstantColor(kCGColorBlack)];
self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session];
[self.previewLayer setFrame:[previewViewLayer bounds]];
[self.previewLayer setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
[previewViewLayer addSublayer:self.previewLayer];
// Start the session
[self.session startRunning];
// Create a device input for the device and add it to the session
NSError *error = nil;
AVCaptureDeviceInput *newVideoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:self.videoDevice error:&error];
[self.session addInput:newVideoDeviceInput];
self.videoDeviceInput = newVideoDeviceInput;
[self.session commitConfiguration];
}
- (void)getDevice {
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *device in devices) {
NSLog(#"Device name: %#", [device localizedName]);
self.videoDevice = device;
}
}
Solved:
I moved [self initSession];from - (void)viewDidLoadto - (void)viewDidLayout
Update:
I ran into more problems later with - (void)viewDidLayout so eventually I moved to - (void)viewDidAppear

Cannot set property of UIImageView subclass

I've subclassed UIImageView, it's called ACCascadeImageView.
#interface ACCascadeImageView : UIImageView{
BOOL isSpotlight;
}
#property (assign, nonatomic) BOOL isSpotlight;
-----
#implementation ACCascadeImageView
#synthesize isSpotlight;
I then create instances like so, and add a gesturerecognizer..
ACCascadeImageView *imageview =
[[ACCascadeImageView alloc] initWithFrame:imageframe];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handleSingleTap:)];
[imageview addGestureRecognizer:singleTap];
In the handleSingleTap method, I loop through my UIScollView subviews, and I try to do this for each one...
(imageview in this scope is [gestureRecognizer view])
[imageview setIsSpotlight:NO];
But I get this...
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UIImageView setIsSpotlight:]: unrecognized selector sent to instance 0x6888be0'
Why has my ACCascadeImageView suddenly become UIImageView? I apologize if I'm doing something stupid, but I've subclassed UIImageView before just fine. I'm confused.
I should say that I've NSLog'd [imageview class] and I get, "ACCascadeImageView".
Here's the problem:
NSArray *cascadeImages = [PhotoCascade subviews];
for (ACCascadeImageView *v in cascadeImages){
NSLog(#"RESPONDS: %d", [v respondsToSelector:#selector(setIsSpotlight:)]);
[v setIsSpotlight:NO];
}
I get :
RESPONDS: 1
RESPONDS: 0
Then it dies.
You can't be sure [gestureRecognizer view] is your UIImageView. To check this try NSLog(#"view: %#", [gestureRecognizer.view class]);. My tests says it's just UIView.
If you're adding gesture recognizer to your image view the selector will be fired only when the user taps this view. So you could omit those checks at all.
By your results, and since you only test once per object, it seems the first object in the array is your custom subview, but the second is not. Maybe somehow one of the objects in cascadeImages isn't an ACCascadeImageView. Step through the array and perform introspection on each one, logging the results, to make sure the array only contains ACCascadeImageViews.
You're saying that your handleSingleTap is returning TRUE in response to respondsToSelector:#selector(setIsSpotlight:), but then when you try to use setIsSpotlight, it fails? That is a mystery.
For example, I've created this super simple example, and it works as you'd expect:
#import "ViewController.h"
#interface Test : UIImageView
#property (assign, nonatomic) BOOL isSpotlight;
#end
#implementation Test
#synthesize isSpotlight;
#end
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
Test *test = [[Test alloc] initWithFrame:self.view.frame];
[self.view addSubview:test];
test.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handleSingleTap:)];
[test addGestureRecognizer:tap];
}
- (void)handleSingleTap:(UIGestureRecognizer *)sender
{
Test *imageview = (Test *)[sender view];
NSLog(#"%s %d", __FUNCTION__, [imageview respondsToSelector:#selector(setIsSpotlight:)]);
[imageview setIsSpotlight:NO];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
#end
The problem has to be something simple, but with limited code snippets provided in your question, it's not obvious what the problem is. But the code you've provided above would not manifest the sort of problem you describe. There must be some rogue UIImageView in your app!

Add image to UISegmentedControl from another controller

MainViewController contains UISegmentedControl with 3 segments.
SliderSubViewController contains a UISlider and -(void) sliderValueChanged:(UISlider*)sender
I want to add a code like this in SliderSubViewController.m but I'm stuck on how to access the UISegmentedControl and add an image:
- (void)viewDidLoad
{
[super viewDidLoad];
mainController = [[MainViewController alloc] initWithNibName:nil bundle:nil];
[minPrisSlider addTarget:self
action:#selector(sliderValueChanged:)
forControlEvents:UIControlEventValueChanged];
- (void)sliderValueChanged:(UISlider*)sender
{
NSUInteger index = (NSUInteger)(minPrisSlider.value + 0.5); // Round the number.
[minPrisSlider setValue:index animated:NO];
int progressAsInt =(int)(minPrisSlider.value + 0.5f);
NSString *newText =[[NSString alloc] initWithFormat:#"%d,-",progressAsInt];
minPrisText.text = newText;
if (minPrisSlider.value != 70) {
/*mainController.segmentedControl add main bundle image named "CheckboxChecked.png"
to current segment*/
}
}
If you have added SliderViewController as subview on MainViewController, One approach you can try is to just declare object of MainViewController in SliderViewController write #property and #synthesize, dont allocate it and while adding SliderView as subview just assign it as
sliderviewcontrollerObject.mainViewControllerObject = self;
now you can access segmentedControl from sliderview ass self.mainViewControllerObject.segmentedbar
Also you can try delegate approach.

UIImage Causing Views All Throughout the iPhone to Turn Black

Alright, this problem is rather bizarre, and I'm 99% positive at this point it's not a retain/release error. Basically I'm using UIImagePickerController to grab an image from either the library or the camera, but the resulting image causes some... strange things to happen. Though it's laggy to pull the image up in a detail view controller containing a UIImageView, the real problem is that if I repetitively pull up the view controller and dismiss it, eventually parts of the image will have disappeared!!! More disturbingly, if I attempt to pull it up again after this has happened, the whole image will have turned black, and other UIViews throughout both my App AND the iPhone itself will either flicker wildly or have turned black!!!! For example, both the iPhone wallpaper and the initial "slide to unlock" panel turn black and flicker, respectively... It makes no difference whether the photo came from the library or the camera. The problem is entirely averted (no lag, no blackness) if I do something like this:
//UIImage* image = (UIImage*)[info objectForKey:UIImagePickerControllerOriginalImage];
UIImage* image = [[UIImage alloc] initWithData:
[NSData dataWithContentsOfURL:
[NSURL URLWithString:
#"http://wild-facts.com/wp-content/uploads/2010/07/Diving_emperor_penguin.jpg"]]];
Thus I can't imagine the problem having to do with anything other than the UIImagePickerController. Note that I'm still creating and dismissing it-- I'm just not grabbing the image out of it.
At first I thought the image was simply being overreleased, and the disappearing black chunks were parts of memory being overwritten. However, changing the image's retain count makes no difference. Then I thought, maybe the image is too large and somehow not getting properly released when I dismiss the UIImageView! Yet downloading a several MB image from the internet will not replicate the error. Then I thought, maybe the UIImagePickerController is disposing of the image, regardless of retain count! But copying the image failed as well. Furthermore, how could any of these things effect views that exist as deep as the iOS level?! I've researched, experimented, and Googled and no one has encountered this problem except for me... yet I'm not doing particularly strange! Is this an Apple issue? Did I forget something obvious? I've scanned up and down the documentation and guides to no avail, but perhaps I missed something.
None of this has worked:
Incrementing the retain count
Using [image copy]
None of this has replicated the problem with the downloaded image:
Decrementing the retain count
Downloading an image of size greater than 1 MB with large dimensions
I'm using the latest Verizon iPhone with iOS 4.2.8 (base SDK "overriden" to 4.3, whatever that means). 4.2.8 is the latest possible one for Verizon, though 4.3 is available for iPhones using AT&T.
Here's the code in glorious detail. I'm not yet checking for device compatibility, but it shouldn't matter concerning this. Perhaps I forgot some setting with the UIImagePickerController?
Quick Overview: I display an action sheet, then based on the user's input, display the image picker. I save the image as a transformable attribute on a Core Data object (delivery) using a custom transformer. I later hand the image to a detail view controller to display to the user.
IGDeliveryVC.m (parts of it, anyways. It's a tableview displaying the delivery's added media)
- (void)refresh
{
[mediaDisplayArray release];
NSSortDescriptor* sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:#"displayIndex" ascending:YES];
mediaDisplayArray = [[NSMutableArray alloc] initWithArray:
[delivery.deliveryMedia sortedArrayUsingDescriptors:
[NSArray arrayWithObject:sortDescriptor]]];
if (mediaDisplayArray == nil)
mediaDisplayArray = [[NSMutableArray alloc] init];
[self.tableView reloadData];
}
- (void)onAddMedia:(id)sender
{
#if TARGET_IPHONE_SIMULATOR
UIImage* image = [[UIImage alloc] initWithData:
[NSData dataWithContentsOfURL:
[NSURL URLWithString:
#"http://wild-facts.com/wp-content/uploads/2010/07/Diving_emperor_penguin.jpg"]]];
[delivery addImage:image];
[self refresh];
[image release];
return;
#endif
UIActionSheet *options = [[UIActionSheet alloc] initWithTitle:#"Add Media from..."
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:#"Camera", #"Library", nil];
[options showFromToolbar:self.navigationController.toolbar];
[options release];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex != 0 && buttonIndex != 1)
return;
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.mediaTypes = [NSArray arrayWithObjects:#"public.image",#"public.movie", nil];
switch (buttonIndex)
{
case 0:
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
break;
case 1:
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
break;
}
[self presentModalViewController:picker animated:YES];
}
- (void) imagePickerControllerDidCancel: (UIImagePickerController *) picker
{
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
[picker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString* mediaType = (NSString*)[info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:#"public.image"])
{
UIImage* image = (UIImage*)[info objectForKey:UIImagePickerControllerOriginalImage];
//UIImage* image = [[UIImage alloc] initWithData:
// [NSData dataWithContentsOfURL:
// [NSURL URLWithString:
// #"http://wild-facts.com/wp-content/uploads/2010/07/Diving_emperor_penguin.jpg"]]];
[delivery addImage:image];
}
else if ([mediaType isEqualToString:#"public.movie"])
{
NSString* videoURL = (NSString*)[info objectForKey:UIImagePickerControllerMediaURL];
[delivery addVideo:videoURL];
}
else
{
NSLog(#"Error: imagePickerController returned with unexpected type %#", mediaType);
}
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
[picker release];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
IGMedia* media = [mediaDisplayArray objectAtIndex:indexPath.row];
UIViewController* detailViewController =
[media isMemberOfClass:[IGMediaImage class]]
? [[IGMediaImageDetailVC alloc] initWithImage:((IGMediaImage*)media).image]
: nil;
if (detailViewController != nil)
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
IGMediaImageDetailVC.h (I use a xib :P )
#import <UIKit/UIKit.h>
#interface IGMediaImageDetailVC : UIViewController {
}
#property (nonatomic, retain) UIImage* image;
#property (nonatomic, retain) IBOutlet UIImageView* imageView;
- (id)initWithImage:(UIImage*)anImage;
#end
IGMediaImageDetailVC.m
#import "IGMediaImageDetailVC.h"
#implementation IGMediaImageDetailVC
#synthesize image;
#synthesize imageView;
- (id)initWithImage:(UIImage*)anImage
{
self = [super initWithNibName:#"IGMediaImageDetailVC" bundle:nil];
if (self)
{
self.image = anImage;
}
return self;
}
- (void)dealloc
{
[image release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.imageView.image = self.image;
}
- (void)viewDidUnload
{
[super viewDidUnload];
[imageView release];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#end
If there's anything I can do to make this post more legible, please let me know. I'll add things that don't work/replicate the problem to the appropriate list. Thanks for taking the time to read this!
I just figured out the problem, had to do with excessive memory use. Thanks goes to this amazing post: https://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more Basically, before ever displaying the image, I divide each dimension by 4, resulting in a total 1/16th of the memory I was using before. Here's the method I used (as per the awesome post):
+ (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize;
{
UIGraphicsBeginImageContext(newSize);
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
In the method call, I pass in CGSizeMake(image.size.width/4, image.size.height/4)
Hope this was helpful!

How can I display my images in my viewController the same as the below screen shot?

In my iPad program I have an array which holds images. How can I display my all images (from an image array) in my viewController the same as the below screen shot? Is there a good way to do it, any sample application paths to refer or sample code?
I need the following functionality.
Tapping an image will show it full screen
A close button to close this view as the same as the screen shot.
Two buttons to display the remaining and previous images.
A sample screen shot is attached below. We can see that the below application is showing all images at the right side of the screen.
Alright, this should be easy, though a bit of coding is needed.
Start out with a simple view based app template.
I don't know where the images come from so I just put all the images to be shown in the resources folder.
The view controller PictureViewController will accept an array of UIImages and should be presented modally. I'll post the code below.
The code to show the PictureViewController is placed in the view controller created by the template. I just added a simple UIButton to the view to trigger an action which looks something like this:
- (IBAction)onShowPictures
{
// Load all images from the bundle, I added 14 images, named 01.jpg ... 14.jpg
NSMutableArray *images = [NSMutableArray array];
for (int i = 1; i <= 14; i++) {
[images addObject:[UIImage imageNamed:[NSString stringWithFormat:#"%02d.jpg", i]]];
}
PictureViewController *picViewController = [[PictureViewController alloc] initWithImages:images];
[self presentModalViewController:picViewController animated:YES];
[picViewController release];
}
The view controller's view was created with interface builder, looking like this:
PictureViewController.xib
View Hierarchy
The fullscreen image is linked to an outlet fullScreenImage seen in the following header file. Actions are connected as well.
I've set the fullscreen imageView's content mode to Aspect Fit.
The Thumbnails will be added dynamically with code. Here's the view controller's code
PictureViewController.h
#interface PictureViewController : UIViewController
{
NSMutableArray *imageViews;
NSArray *images;
UIImageView *fullScreenImage;
int currentPage;
}
#property (nonatomic, retain) NSMutableArray *imageViews;
#property (nonatomic, retain) NSArray *images;
#property (nonatomic, retain) IBOutlet UIImageView *fullScreenImage;
- (id)initWithImages:(NSArray *)images;
- (IBAction)onClose;
- (IBAction)onNextThumbnails;
- (IBAction)onPreviousThumbnails;
#end
PictureViewController.m
The define MAX_THUMBNAILS on top defines the maximum of thumbnails seen. A UITapGestureRecognizer will take care of the tap events for the thumbnails. Adjust the CGRectMake in setupThumbnailImageViews to position the thumbnails as you wish. This controller is just a basic approach without orientation support.
#import "PictureViewController.h"
#define MAX_THUMBNAILS 6
#interface PictureViewController ()
- (void)showSelectedImageFullscreen:(UITapGestureRecognizer *)gestureRecognizer;
- (void)setupThumbnailImageViews;
- (void)setThumbnailsForPage:(int)aPage;
- (UIImage *)imageForIndex:(int)anIndex;
#end
#implementation PictureViewController
#synthesize imageViews, images, fullScreenImage;
- (id)initWithImages:(NSArray *)someImages
{
self = [super init];
if (self) {
self.images = someImages;
self.imageViews = [NSMutableArray array];
currentPage = 0;
}
return self;
}
- (void)viewDidLoad
{
self.fullScreenImage.image = [images objectAtIndex:0];
[self setupThumbnailImageViews];
[self setThumbnailsForPage:0];
}
- (void)showSelectedImageFullscreen:(UITapGestureRecognizer *)gestureRecognizer
{
UIImageView *tappedImageView = (UIImageView *)[gestureRecognizer view];
fullScreenImage.image = tappedImageView.image;
}
- (void)setupThumbnailImageViews
{
for (int i = 0; i < MAX_THUMBNAILS; i++) {
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20.0,
166.0 + (130.0 * i),
130.0,
90.0)];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
action:#selector(showSelectedImageFullscreen:)];
tapGestureRecognizer.numberOfTapsRequired = 1;
tapGestureRecognizer.numberOfTouchesRequired = 1;
[imageView addGestureRecognizer:tapGestureRecognizer];
[tapGestureRecognizer release];
imageView.userInteractionEnabled = YES;
[imageViews addObject:imageView];
[self.view addSubview:imageView];
}
}
- (void)setThumbnailsForPage:(int)aPage
{
for (int i = 0; i < MAX_THUMBNAILS; i++) {
UIImageView *imageView = (UIImageView *)[imageViews objectAtIndex:i];
UIImage *image = [self imageForIndex:aPage * MAX_THUMBNAILS + i];
if (image) {
imageView.image = image;
imageView.hidden = NO;
} else {
imageView.hidden = YES;
}
}
}
- (UIImage *)imageForIndex:(int)anIndex
{
if (anIndex < [images count]) {
return [images objectAtIndex:anIndex];
} else {
return nil;
}
}
#pragma mark -
#pragma mark user interface interaction
- (IBAction)onClose
{
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction)onNextThumbnails
{
if (currentPage + 1 <= [images count] / MAX_THUMBNAILS) {
currentPage++;
[self setThumbnailsForPage:currentPage];
}
}
- (IBAction)onPreviousThumbnails
{
if (currentPage - 1 >= 0) {
currentPage--;
[self setThumbnailsForPage:currentPage];
}
}
#pragma mark -
#pragma mark memory management
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
[images release];
}
- (void)viewDidUnload
{
[super viewDidUnload];
[imageViews release];
[fullScreenImage release];
}
- (void)dealloc
{
[images release];
[imageViews release];
[fullScreenImage release];
[super dealloc];
}
#end
The result: