Ipad 从UITableView中拖动按钮

Ipad 从UITableView中拖动按钮,ipad,ios4,uitableview,uigesturerecognizer,Ipad,Ios4,Uitableview,Uigesturerecognizer,我有一个由自定义单元格组成的TableView。此单元格包含一个标签和一个按钮。现在,我在单元格中的按钮中添加了一个PangestureRecognitor。我的问题是,当我尝试开始移动/拖动按钮时,按钮会正确移动,但不幸的是,按钮隐藏在TableView后面。我怎样才能走到它前面。自定义单元格是以编程方式创建的,TableView也是如此。我的手势处理方法如下: -(无效)装甲:(UIPangestureRecognitor*)带事件的手势识别器:(id)事件 { } -(无效)Adjust

我有一个由自定义单元格组成的TableView。此单元格包含一个标签和一个按钮。现在,我在单元格中的按钮中添加了一个PangestureRecognitor。我的问题是,当我尝试开始移动/拖动按钮时,按钮会正确移动,但不幸的是,按钮隐藏在TableView后面。我怎样才能走到它前面。自定义单元格是以编程方式创建的,TableView也是如此。我的手势处理方法如下:

-(无效)装甲:(UIPangestureRecognitor*)带事件的手势识别器:(id)事件
{

}

-(无效)AdjustAnchorPointForgestureRecognitor:(UIGestureRecognitor*)GestureRecognitor { if(GestureRecognitzer.state==UIGestureRecognitzerStateStarted | | |(GestureRecognitzer.state==UIGestureRecognitzerStateChanged)) { UIView*piece=gestureRecognitor.view; CGPoint locationInView=[手势识别器位置INVIEW:piece]; CGPoint LOCATIONINSOPERVIEW=[GestureRecognitor locationInView:piece.superview]; piece.layer.anchorPoint=CGPointMake(locationInView.x/piece.bounds.size.width,locationInView.y/piece.bounds.size.height); 工件中心=观察位置; } }

代码是基于苹果的代码建模的

这里是解决方案:


希望这有帮助

谢谢您的回复。我已经在图像视图的帮助下实现了这一点。但这些要求迫使我拖动按钮,而不是它的图像。当我添加一个图像时,它被添加到主视图中,即self.view和ergo,它工作正常。但是如果一个按钮嵌入到tableview中,它会变得相当复杂。除了在tableview单元格的内容视图中添加按钮之外,还有其他方法添加按钮吗?
UIView *piece = [gestureRecognizer view];
[self adjustAnchorPointForGestureRecognizer:gestureRecognizer];

//*******************Dragging Ended*************************************

if([gestureRecognizer state]==UIGestureRecognizerStateEnded)
{
    [tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];

}

//*******************Dragging Started andchanged*************************************

if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] ==UIGestureRecognizerStateChanged) 
{

    CGPoint translation = [gestureRecognizer translationInView:[piece superview]];
    [piece setCenter:CGPointMake([piece center].x + translation.x, [piece center].y + translation.y)];
    [gestureRecognizer setTranslation:CGPointZero inView:[piece superview]];
    CGPoint moveLocation=[gestureRecognizer locationInView:piece];
    NSIndexPath *indexPath=[tableView indexPathForRowAtPoint:moveLocation];