removing the last touched uiimage

Discussion in 'iOS Programming' started by tacotester1, Mar 11, 2014.

  1. tacotester1 macrumors member

    Joined:
    Dec 19, 2013
    #1
    i have app where u can pick fashion accessories like designer purses
    and shoes and put on to a cork board. to make cool trend inspired boards.


    there are a bunch of these little fashion graphics that you can pick grpahics from a menu and put them on to cork board and move to make a cool collection.

    does anyone know of any key terms or tips for
    how i could tell which was the last graphic touch. so i can hide or "delete" it from the corkboard?



    any terms i can use to further figure this out or a tutorial would be great!

    thank you !:apple:
     
  2. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #2
    Really, UIImage? Explain how you are drawing those images to the cork board. Are you using a UIView drawRect, CALayers, or UIImageViews?

    To keep track of touches perhaps an NSMutableArray would work. When you add an image, you'd use addObject to place it at the end of the array. When you touch another object to move or alter it, you'd remove it from the array and add it back to the end. (I don't see a method for swapping locations) Finally, when you want to remove the object from the board you'd fetch the last object in the array to know which one to work with for the removal process, and remove it from the array also.
     
  3. tacotester1 thread starter macrumors member

    Joined:
    Dec 19, 2013
    #3
    awesome thank you i will check this out!

    yes just simple uiimageviews that u can make appear by pressing the corresponding icon button. i will need to read up on your suggestion. I appreciate it!
     
  4. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #4
    If you bringSubviewToFront when you touch to adjust an existing image, then that would be the last item touched and could be found via
    Code:
    [yourMasterContentView subviews];
    Since that returns an array, you could choose the last object and remove it.
     
  5. tacotester1 thread starter macrumors member

    Joined:
    Dec 19, 2013
    #5
    thanks ill check that out too
    i was thinking like this for removal

    Code:
    [self.HelloArray removeLastObject];
    thanks again!
     
  6. waterskier2007 macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #6
    Not swapping per se, but NSMutable array has
    Code:
    replaceObjectAtIndex:withObject:
    
     
  7. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #7
    I would suggest setting userInteractionEnabled on your image views, then attaching tap gesture recognizers and/or pan gesture recognizers to them. That would let the user tap on them and let you call a method when the user does either of those things. You should be able to find plenty of tutorials online that show how to drag image views around using a pan gesture recognizer (UIPanGestureRecognizer.)

     
  8. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #8
    I should have used the word move.

    The method you mention removes the object currently at that index with the new object. We don't know that is what is wanted.

    ----------

    In that context I meant remove the UIImageView from its superview, not the returned array.
     
  9. waterskier2007 macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #9
    Yes, but unless I am misunderstanding the need, you could remove the object from it's original place and then replace the desired index with this method
     
  10. tacotester1 thread starter macrumors member

    Joined:
    Dec 19, 2013
    #10
    awesome thanks for all the info!

    i have got all the gesture recognizers set

    i will read up on all your suggestions
    and hopefully get some solid info to post here

    thanks again!

    ----------

    Code:
    [self.view bringSubviewToFront:imageView];
    I see what your saying that is great idea
    thank u!
     

Share This Page