views:

53

answers:

1

This is driving me bonkers, have been on it ages and still can get the thing to do what I want!

My view is set out like this:

RootViewController contains (UIView)flipView

FlipView contains (UiView)firstView

FirstView contains a scrollview and a load of imageviews

Scrollview contains a series of custom imageViews

I can drag the custom imageViews left and right and whichever one I drag it appears above all other custom imageViews in the scrollview because of this line in the custom UIImageViews touchesBegan method:

[[self superview] bringSubviewToFront:self];

Great! But.....

Although I can drag vertically and the custom imageView leaves the bounds of the scrollview as required I cannot get it to appear above any of the imageviews that are on firstview?

I also have found that if I display the point.y value when I first touch the imageview to be dragged it shows 24 as I start to drag up to take it off the scrollview it goes to 26 and then stays at that value even though I can drag it all the way to the top of the screen, behind all the other imageviews?

I have obviously missed the bleeding obvious....obviously....help please?

Thanks

+1  A: 

bringSubviewToFront: will only work within that view, i.e. your scrollview needs to be in front of all those other imageViews, or they will cover your scrollview. If you want to remove the image from the scrollview, it might be worth removing it and adding it on top of everything directly to your firstView while dragging.

Eiko
Thanks for the reply! I see what you mean about the scrollview bringing to front, will try that. However I did think of your second idea before but do not understand how I would transfer the touch event that is dragging the original imageview to a newly created one? A tip would be awesome....! Thanks
user7865437
If you are handling the event in the image view, you stay in the same object for touch handling. But thinking about it, I'm not sure what UIKit thinks about touches when altering the view hierarchy. *Maybe* it will cancel the event, but it's worth a try.
Eiko
Yeah, but I don get how you can make a imageview that is moving create a new imageview where it is and transfer touches to the new one? Im not sure that is possible?
user7865437
No new imageview, just [self removeFromSuperview]; and [firstView addSubview:self];
Eiko
Will try your method in a sec, looks interesting!I just managed to get it to work using your first idea, although I guess it is messy?call this from the moving imageview:// move the scrollview to top[(CustomScrollView *)[self superview] toTop];// now move the moving imageview to top of scrolling imageview[[self superview] bringSubviewToFront:self];and it works! But does the populous think this a carbunkle of a solution?:-)
user7865437
the way my app is both ways work, but the bringing the scrollview to front is the best way for my purposes. Also in both cases I have to call back up the chain of views to do the necessary. Thanks for the tips, two new things learned ;-)
user7865437