Advertise here




Advertise here

Howdy, Stranger!

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

Remove Images From Imageview...

jitendrajitendra Posts: 59New Users @
I have 2 array both array contains 20 images.loading first 20 array images to imageview images display using scroll view. scroll Horizontally. when i want to load the new 20 images. previous array images still present to imageview. that new 20 images adding at upper of that older 20 images. how may i remove that previous array images from imageview.

help me out this thanks in advance.

Replies

  • deeptikadeeptika Posts: 115Registered Users @ @
    Hi,

    Before assign the new array images you first set the imageview to nil and then assign the images ie
    image view.image=nil;
    imageview.image=[UIImage image named:@xxx.png];
  • jitendrajitendra Posts: 59New Users @
    mage view.image=nil;
    @deeptika i have tried this one but still the old array image not clear from imageview.
  • amitchauhanamitchauhan Posts: 28Registered Users @
    You have to have UIImageViewArray [20], and before placing new image, you have to remove old image [imgView[0] removeFromSuperView]; from scrollview.
  • jitendrajitendra Posts: 59New Users @
    @ amitchauhanamitchauhan no this is also not working...
  • amitchauhanamitchauhan Posts: 28Registered Users @
    @Jitendra It will work 100%, You are doing something wrong what I'm trying to explain.
  • dev666999dev666999 Posts: 3,632New Users @ @ @ @ @
    edited June 2013
    Put this at the beginning of your ScrollView code... before you load the new images.


    //removes the images from scrollview so that you can reload with new images.
    for (UIView* view in scrollView.subviews)
    {

    [view removeFromSuperview];

    }


    Be sure to change "scrollView.subviews" to your scrollView name.
  • Duncan CDuncan C Posts: 9,116Tutorial Authors, Registered Users @ @ @ @ @ @ @
    jitendra said:

    I have 2 array both array contains 20 images.loading first 20 array images to imageview images display using scroll view. scroll Horizontally. when i want to load the new 20 images. previous array images still present to imageview. that new 20 images adding at upper of that older 20 images. how may i remove that previous array images from imageview.

    help me out this thanks in advance.

    You aren't explaining your problem very well. You say you have an array of 20 images, but they you say you have all 20 images in an image view.

    It sounds like you have 20 image views laid out side by side in a scroll view.

    You should set up and IBOutletCollection with all your image views in it, in order.

    Then, when you want to load images into those images, you can just loop through the IBOutletCollection, installing an image into each image view in your scroll view.

    It's cleaner and more efficient if you leave the image views in place and replace their images rather than removing and recreating 20 image views from your scroll view each time.

    (That's assuming I understand what you are trying to do - not a good assumption given how poorly you described your problem.)
    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.