hi i am new to iphone. what i am doing is displaying 20 images as grid and display selected image in image view .here i consider each image as button. now what i need is after 4 button taps image are sorted in grid view how can i done this pls help me i am very lucky if u post some code thank u
+1
A:
It depends on what you mean by 'sorted'. Are they randomly shuffled or are they sorted in some sort of order?
Basically you can: * Create a grid if UIImageView objects (Put references to them in an array) * Create an array of image names or UIImage objects. * Sort the array however you want. * Iterate through the array and replace the image in each UIImageView with the UIImage from the array.
I can't really give you code without knowing more about how you want to sort them.
joelm
2010-08-06 14:17:13
how to put references to UIImageVIew objects
MaheshBabu
2010-08-09 05:33:39
Are you creating the images in Interface Builder or programmatically?If you are creating them in the program, you could so something like: NSMutableArray *imageArray = [NSMutableArray arrayWithCapacity:20]; for (int i = 0; i < 20; i++) { UIImage *newImage = [[UIImage alloc] initWithContentsOfFile:filePath]; [imageArray addObject:newImage]; [newImage release]; }If you are creating them in IB, just:NSArray *imageArray = [NSArray arrayWithObjects: image1, image2, nil]; // etc
joelm
2010-08-09 14:07:41