एक्सकोड में कोई छवि छूने पर आप कैसे पता लगा सकते हैं? मैं एप्पल प्रलेखन पर ध्यान दिया है और यह वास्तव में भ्रमित कर रहा है ... मैंने देखा:छवि को छूने पर कैसे पता लगाया जाए
if (CGRectContainsPoint([imageView frame], location))
लेकिन मेरी छवि अभी भी नहीं ले जाएगा। मैं touchesBegan + touchesMoved उपयोग करने की कोशिश, और हाँ करने के लिए छवि के userInteractionIsEnabled निर्धारित करते हैं, लेकिन यह अभी भी यह पता नहीं लगा होगा :(
संपादित करें: आप अपने सभी महान सुझाव के लिए बहुत बहुत शुक्रिया अंत में, मैं वास्तव में इसे जितना संभव हो सके उतना सरल बनाना चाहता था, और मुझे पता था कि मेरा कोड काम करना चाहिए, इसलिए मैंने इसके साथ झुकाव रखा, और अच्छी रात की नींद के बाद, मुझे एहसास हुआ कि यह काफी सरल समाधान था:
इन मेरे स्पर्श हटाए गए:
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
CGRect shapeRect = [imageView frame];
CGRect dropSquareRect = [dropSquare frame];
CGPoint touchLocation = CGPointMake(location.x, location.y);
if (CGRectContainsPoint(shapeRect, touchLocation))
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
[imageView setCenter:touchLocation];
[UIView commitAnimations];
}
if (CGRectIntersectsRect(shapeRect, dropSquareRect))
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
self.imageView.alpha = 0;
self.imageView.center = CGPointMake(dropSquare.center.x, dropSquare.center.y);
self.imageView.transform = CGAffineTransformMakeScale(0.8, 0.8);
[UIView commitAnimations];
यह किया जाना चाहिए ... भगवान का जवाब –