Note that there are some explanatory texts on larger screens.

plurals
  1. POView goes out of a View Boundary
    primarykey
    data
    text
    <p>I have a Background view (UIImageView) in that i am adding a view(UIView). this contentView(UIView) contains UIPanGestureRecognizer.</p> <p>I am giving UIPanGestureRecognizer to contentView by bellow code :</p> <pre><code>UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(movePhoto:)]; [panRecognizer setMinimumNumberOfTouches:1]; [panRecognizer setDelegate:self]; [contentView addGestureRecognizer:panRecognizer]; [panRecognizer release]; </code></pre> <p>and then i am adding this contentView to Background View (UIImageView) by bellow code : </p> <pre><code>[imgBG addSubview:contentView]; // here imgBG is Background view. </code></pre> <p>but when i move this contentView it goes out of imgBG.</p> <p>bellow is the method to move contentView</p> <pre><code> [[[(UITapGestureRecognizer*)sender view] layer] removeAllAnimations]; [self.view bringSubviewToFront:[(UIPanGestureRecognizer*)sender view]]; CGPoint translatedPoint = [(UIPanGestureRecognizer*)sender translationInView:self.view]; if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateBegan) { firstX = [[sender view] center].x; firstY = [[sender view] center].y; } translatedPoint = CGPointMake(firstX+translatedPoint.x, firstY+translatedPoint.y); [[sender view] setCenter:translatedPoint]; CGFloat finalX = [sender view].center.x; CGFloat finalY = [sender view].center.y; [[sender view] setCenter:CGPointMake(finalX, finalY)]; </code></pre> <p>I think, here the contentView should remain inside the imgBG as it is the subview of imgBG.</p> <p>Please let me know whether there is a problem in my code or its due to UIPanGestureRecognizer.</p> <p>thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload