iOS removing the last touched uiimage

tacotester1

macrumors member
Original poster
Dec 19, 2013
99
0
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:
 

xStep

macrumors 68010
Jan 28, 2003
2,004
99
Less lost in L.A.
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.
 

tacotester1

macrumors member
Original poster
Dec 19, 2013
99
0
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.
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!
 

xStep

macrumors 68010
Jan 28, 2003
2,004
99
Less lost in L.A.
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.
 

tacotester1

macrumors member
Original poster
Dec 19, 2013
99
0
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.
thanks ill check that out too
i was thinking like this for removal

Code:
[self.HelloArray removeLastObject];
thanks again!
 

Duncan C

macrumors 6502a
Jan 21, 2008
853
0
Northern Virginia
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.)

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:
 

xStep

macrumors 68010
Jan 28, 2003
2,004
99
Less lost in L.A.
Not swapping per se, but NSMutable array has
Code:
replaceObjectAtIndex:withObject:
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.

----------

thanks ill check that out too
i was thinking like this for removal

Code:
[self.HelloArray removeLastObject];
thanks again!
In that context I meant remove the UIImageView from its superview, not the returned array.
 

tacotester1

macrumors member
Original poster
Dec 19, 2013
99
0
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!

----------

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.
Code:
[self.view bringSubviewToFront:imageView];
I see what your saying that is great idea
thank u!