how to sort images in grid view - iphone

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

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.

Related

Looping through images using SpriteWidget

I'm using SpriteWidget in Flutter.
https://github.com/spritewidget/spritewidget
I'm loading images like this:
// Load multiple images
await images.load([
'assets/image_0.png',
'assets/image_1.png',
'assets/image_2.png',
]);
// Access a loaded image from the ImageMap
var image0 = images['assets/image_0.png'];
I'm trying to figure out how to loop through these images so that they are like an animated gif. Show image_0 for half a second, then image_1 for half a second then image_2 for half a second and so on.
I understand that the usual and recommended way to do this is with a spritesheet, but I do not have a sprite sheet, only individual images.
How about using Sequences? You can loop over an array of images based on time.
https://github.com/spritewidget/spritewidget#sequences

how to implement code for displaing images randomly in a row?

hi all how to implement code for displaying different images randomly in a row row. Each row must be have 10 images upto six rows so help me to solve the problem.
I'am not a pro programmer but i also implemented something similar to what you want
You can give a integer tag to every image using
Image-i.tag=i , then
use the function int m=(arc4random()% numOfImages);
to generate a random number and use the image with that tag.
hope this help's.

How to display image and text in a tableviewcell

I have strings like this -
abcdefgh http://abc.abc.jpg adffggjk
The number of images is variable.
How can I display the image and text in a correct sequence in a tabview cell?
This can be achieved by customizing TableViewCell.
Design a data structure in that holds all your data(like a class with String array and image path array). Pass that to your custom cell and there add Lables and ImageView and subview for each string and Image in order you want.
If you have too much of data than you can adjust height of cell in heightForRowAtIndexPath method.
if you have too much of data then designing a UIScrollview and adding them in a Other ScrollView would be better idea.
Hope this is helpful...
Post if you need more help....

how to make "Farm Flip - Memory Match for Kids" like memory based game

i'm about to developp a memory game for children like,i have 6 different images show in in random order in 12 places. note(each image show twice) and i want to know how to set images randomly and how to mach UIImage with animation? any help..
Have a look at the answer by Kristopher at What's the Best Way to Shuffle an NSMutableArray?. You can create an array of 12 images (each repeated twice) & then shuffle the array. Then display the images in the order obtained after shuffling.
Regarding animations, you first need to at least visualize what animation you want. People can then help you achieve that.
HTH,
Akshay

Iphonesdk boundries checking for coloring

im creating and app where user already have an image (with different objects) without colors, i have to check the object and then color with respected color with the touch on that objects. how should i do this. can anyone help me.
I would say that that is non-trivial. I can only give hints since I have not done such an app yet.
First, you need to convert the image into a CGImageRef, for example by doing [uiimage_object CGImage].
Next you need convert the CGImageRef into array of pixel colors. You can follow the tutorial at http://www.fiveminutes.eu/iphone-image-processing/ for sample code. But for your app you need to convert the array into two dimension based on image width and height.
Then, use the coordinate of the user touch to access the exact pixel color value from the array. Next you read off the color values of the surrounding pixels and determine if color is similar to the touched pixel or not (you might need to read some wikipedia articles etc on doing the color comparison). If the color is similar, change the color to the one you want. Recurse until the surrounding color is different (i.e. you hit the boundary).
When you are finished modifying the pixel color value array, you need to convert the array back into CGImageRef using CGImageCreate function. Then you convert back to UIImage using [UIImage imageWithCGImage:imageref].
Now you are on your own to implement the steps into code. It would be unreasonable if you expect me to code all that for you, wouldn't it?