Determining that touch is over an image using touchesMoved: in custom cell?

Here are somethings that might lead you to an answer. If you want touches to be picked up have to override UITableView or your UITableViewCell. By overriding the touches in your UITableViewCell you can then evaluate which view was touched like you are currently doing.

A point to note if you touch down on the content view and move over the image view the view you are touching (and therefore are returned by the touches set) will still be the content view. If you touch down on the UIImageView you will get that view returned and will cause your NSLog to be written out.

Here are somethings that might lead you to an answer. If you want touches to be picked up have to override UITableView or your UITableViewCell. By overriding the touches in your UITableViewCell you can then evaluate which view was touched like you are currently doing.

A point to note if you touch down on the content view and move over the image view the view you are touching (and therefore are returned by the touches set) will still be the content view. If you touch down on the UIImageView you will get that view returned and will cause your NSLog to be written out. Just as an extra point you have to set, self.

Flag setUserInteractionEnabled:YES; or you can check the interaction checkbox in the attribute inspector. To make sure the touch events are fired. I am not sure if this exactly answers your question but I hope it helps.

Here is the problem I had and the solution hopefully this helps. My problem was that I had a UIView which had a UITableView on it and several other smaller UIViews. I wanted to be able to drag the smaller views and drop them onto the cells in the table setting the UITableViewCell image to match the CALayer of the smaller view touched.

Here is the touch code I used. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *t =touches anyObject; UIGraphicsBeginImageContext(t.view.bounds. Size); t.view.

Layer renderInContext:UIGraphicsGetCurrentContext(); UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); self. DraggedView = UIImageView alloc initWithImage:img; CGPoint centre = touches anyObject locationInView:self. View; self.

DraggedView setCenter:centre; self. DraggedView setAlpha:0.5; self. View addSubview:self.

DraggedView; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ CGPoint centre = touches anyObject locationInView:self. View; self. DraggedView setCenter:centre; } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ CGPoint centre = touches anyObject locationInView:self.

View; UIView *hit = self. TableView hitTest:centre withEvent:event; UIGraphicsBeginImageContext(self.draggedView.bounds. Size); self.draggedView.

Layer renderInContext:UIGraphicsGetCurrentContext(); UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); if(hit! =nil){ UITableViewCell *tvc = (UITableViewCell *)hit. Superview; tvc.

ImageView setImage:img; UITableView *tv = (UITableView *)tvc. Superview; NSIndexPath *ip = tv indexPathForCell:tvc; tv deselectRowAtIndexPath:ip animated:YES; } self. DraggedView removeFromSuperview; self.

DraggedView = nil; } The hit test in the touchesEnded returns the UITableViewCellContentView so to get the Cell I just ask for its super view.

Wow! Thanks a lot! Was very helpful.

– Vins Nov 2 at 18:08.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions