Ios 无法将UIImageView拖到UIScrollview的末尾?

Ios 无法将UIImageView拖到UIScrollview的末尾?,ios,objective-c,iphone,cocoa-touch,uiscrollview,Ios,Objective C,Iphone,Cocoa Touch,Uiscrollview,我有一个UIScrollview,在水平方向上有大量内容。现在我想将UIImageView拖到UIScrollView的末尾。为此,我使用以下代码 - (void) setUpLeftGesture{ _leftControlImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 80, 25)]; [_leftControlImageView setBackgroundColor:[UIColor ye

我有一个UIScrollview,在水平方向上有大量内容。现在我想将UIImageView拖到UIScrollView的末尾。为此,我使用以下代码

- (void) setUpLeftGesture{

    _leftControlImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 80, 25)];
    [_leftControlImageView setBackgroundColor:[UIColor yellowColor]];
    [_leftControlImageView setImage:[UIImage imageNamed:@"marker_left_normal"]];
    //add gesture events
    UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleLeftSelector:)];
    [_leftControlImageView addGestureRecognizer:panGestureRecognizer];
    [_leftControlImageView setUserInteractionEnabled:YES];
    [scrollView addSubview:_leftControlImageView];

}

-(void)handleLeftSelector:(UIPanGestureRecognizer *)panGestureRecognizer{

    CGPoint point = [panGestureRecognizer locationInView:self];
    _leftControlImageView.center = point;
}
当我执行上述代码时,我可以拖动_leftControlImageView(我的UIImageView)在屏幕大小内移动良好

如果尝试拖动到UIScrollView的末尾,UIImageView将不会拖动。我又回到了以前的位置。我不知道为什么会这样


提前谢谢。任何人都可以提供将视图拖动到UIScrollview末尾的建议。

将imageview添加到内容视图中而不是滚动视图中。

如果要将视图拖动到UIScrollview末尾。请确保您的视图(CustomView)是否扩展到UIScrollView。我认为UIPangestureRecognitor将允许我们在它的超级类中执行拖放操作

因此,将您的超类从UIView更改为UIScrollView,如下所示

@interface CustomView : UIView

通过这样做,您可以将UIView拖到UIScrollView的末尾

@interface CustomView : UIScrollView