-1

I have one UIView. Inside this view, i have added UIScrollView.And scrollview containing one UIButton.Everything is created by programmatically.Initially content size of scrollview is same as view size.User can drag button inside.Now if button reach at corner or any side of scrollview.If it is dragged there for more than 1 second than content size of scrollview should increase on that side.I dont have any idea about this technique or using which method ,we can get it.Please help me.Any hint will be appreciated.Thanking you.

4

1 回答 1

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)];
   }
 }
于 2013-10-10T09:18:07.777 回答