Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Gettimg images as per array index

jitendrajitendra Posts: 59New Users @
edited May 2013 in iOS SDK Development
i am developing one app in that app i am loading 13 images to UIImageview when user Tapped Doubble Tapped on Particular one image another 13 images on same ImagevVew.


NSMutableArray * FrontsCards;



FrontsCards =[[NSMutableArray alloc]initWithCapacity:14];
[FrontsCards insertObject:@1.png atIndex:0];
[FrontsCards insertObject:@2.png atIndex:1];
[FrontsCards insertObject:@3.png atIndex:2];
[FrontsCards insertObject:@4.png atIndex:3];
[FrontsCards insertObject:@5.png atIndex:4];
[FrontsCards insertObject:@6.png atIndex:5];
[FrontsCards insertObject:@7.png atIndex:6];
[FrontsCards insertObject:@8.png atIndex:7];
[FrontsCards insertObject:@9.png atIndex:8];
[FrontsCards insertObject:@10.png atIndex:9];
[FrontsCards insertObject:@11.png atIndex:10];
[FrontsCards insertObject:@12.png atIndex:11];
[FrontsCards insertObject:@13.png atIndex:12];



NSMutableArray * BackCards;

BackCards=[[NSMutableArray alloc]initWithCapacity:14];
[BackCards insertObject:@1.jpg atIndex:0];
[BackCards insertObject:@2.jpg atIndex:1];
[BackCards insertObject:@3.jpg atIndex:2];
[BackCards insertObject:@4.jpg atIndex:3];
[BackCards insertObject:@5.jpg atIndex:4];
[BackCards insertObject:@6.jpg atIndex:5];
[BackCards insertObject:@7.jpg atIndex:6];
[BackCards insertObject:@8.jpg atIndex:7];
[BackCards insertObject:@9.jpg atIndex:8];
[BackCards insertObject:@10.jpg atIndex:9];
[BackCards insertObject:@11.jpg atIndex:10];
[BackCards insertObject:@12.jpg atIndex:11];
[BackCards insertObject:@13.jpg atIndex:12];

displayed first 15 images to uiimageview scroll vertically.
when user doubble tapped on any image load that BackCards images that is also done.



*********************but my requirement is********************************

if user double tapped on [FrontsCards insertObject:@4.png atIndex:3]; 4.png image then load all 13 image
[BackCards insertObject:@4.jpg atIndex:3]; 4.jpg backcardimage to uiimageview.

if user doubble tapped on 5 index image of frontcards array .then load 5 index of image replace all and load on the uiimageview.



help me out this thanks in advance.


Replies

  • Duncan CDuncan C Posts: 9,116Tutorial Authors, Registered Users @ @ @ @ @ @ @
    You've posted code that creates 2 arrays of image names. You never show how you load the images associated with these filenames into one or more images.

    You say "displayed first 15 images to uiimageview scroll vertically." What does that mean? You have a scroll view with each of these images stacked inside it? Or do you load all the images into the animationImages property of a single image view?

    As for this "sentence":
    if user doubble tapped on 5 index image of frontcards array .then load 5 index of image replace all and load on the uiimageview.
    
    I don't have any idea what you are trying to say. You are going to need to be clearer
    Regards,
    Duncan C
    WareTo

    widehead.gif
    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
  • jitendrajitendra Posts: 59New Users @
    my simple question is i am getting all images from nsmutable array randomly so how may get the index value of that images.
  • Duncan CDuncan C Posts: 9,116Tutorial Authors, Registered Users @ @ @ @ @ @ @
    jitendra said:

    my simple question is i am getting all images from nsmutable array randomly so how may get the index value of that images.

    The code you posted shows an array of image names, not an array of images.

    There is no way to work back from images to image names or image indexes. you would need to store the information in the object, or save the array index/file name.

    Saving the array index is easy. Saving the data in the object is much more complex.
    Regards,
    Duncan C
    WareTo

    widehead.gif
    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
  • RickSDKRickSDK Posts: 1,240Registered Users @ @ @ @
    hard to tell what you are trying to do. You have created two arrays that are exactly the same. What is the purpose of having two equal arrays? why not just create one?

    Also, you might as well just use addObject instead, since the array is empty:

    [FrontsCards addObject:@1.png];
    [FrontsCards addObject:@2png];


    etc...
  • Duncan CDuncan C Posts: 9,116Tutorial Authors, Registered Users @ @ @ @ @ @ @
    RickSDK said:

    hard to tell what you are trying to do. You have created two arrays that are exactly the same. What is the purpose of having two equal arrays? why not just create one?

    Also, you might as well just use addObject instead, since the array is empty:

    [FrontsCards addObject:@1.png];
    [FrontsCards addObject:@2png];


    etc...

    Or better yet, use the new object literal syntax:
    NSArray *scratch = @[
      @"1.png",
      @"2.png",
      @"3.png",
      @"4.png",
      @"5.png",
      @"6.png",
      @"7.png",
      @"8.png" ];
    
    NSMutableArray *frontCards = [scratch mutableCopy];
    Or use a for loop:
    int max = 13;
    NSMutableArray *frontCards = [NSMutableArray arrayWithCapacity: max];
    for (int index = 0; index < max; index++)
    {
      NSString *aString = [NSString stringWithFormat: @"%d.png", index+1];
      [frontCards addObject: aString];
    }
    Regards,
    Duncan C
    WareTo

    widehead.gif
    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
Sign In or Register to comment.