我有一个UIView。在这个视图中,我添加了UIScrollView.And scrollview包含一个UIButton.Everything是通过编程方式创建的。最初滚动视图的内容大小与视图大小相同。用户可以在内部拖动按钮。现在如果按钮到达滚动视图的角落或任何一侧。如果在那里拖动超过1秒,滚动视图的内容大小应该在那边增加。我对这种技术或使用哪种方法没有任何想法,我们可以得到它。请帮助我。任何暗示都将受到赞赏。谢谢你。
答案 0 :(得分:0)
您必须为您的UIButton添加UIPangesture识别器。牧场识别器的句柄需要改变UIButton框架以及UIScrollview框架。采取此示例计划供您参考。
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
[myButton setUserInteractionEnabled:YES];
[myButton addGestureRecognizer:panGesture];
你的句柄方法应该是这样的,
-(IBAction)handlePanGesture:(UIPanGestureRecognizer *)sender
{
CGPoint translation = [sender translationInView:self.view];
sender.view.center = CGPointMake(sender.view.center.x + translation.x,
sender.view.center.y + translation.y);
[sender setTranslation:CGPointMake(0, 0) inView:self.view];
//And check sender x,y position with your `scrollview`,if it is crossed then you have to reset the `contentOffset`
// Do the calculation like this
if([sender.view.center].x>yourScrollviewXposition)
{
coordforX=([sender.view.center].x + translation.x);
coordforY=([sender.view.center].y + translation.y);
//based on your calculated x, y position you have to calculate scrollview width and height
[yourScrollView setContentSize:CGSizeMake(width,height)];
}
}