【发布时间】:2016-07-25 12:41:07
【问题描述】:
我有一个横向内容较大的 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 的末尾。
【问题讨论】:
标签: ios objective-c iphone cocoa-touch uiscrollview