如何在Iphone中创建可拖动的Tableview?

时间:2011-10-20 04:47:16

标签: iphone

我想在iphone中创建一个可拖动的tableview,我在一个视图控制器中有两个tableview,一个是普通的tableview,但我想要第二个tableview具有draggable功能,我只想将tableview从底部拖到中心view.I知道如何在视图控制器中拖动图像,但我需要帮助来创建一个可拖动的tableview。请帮助我。 提前谢谢。

@interface UITouchTutorialViewController : UIViewController {
    IBOutlet UIImageView *img;
}

@end

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];
    img.center = location;
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [self touchesBegan:touches withEvent:event];
}

1 个答案:

答案 0 :(得分:0)

@interface UITouchTutorialViewController : UIViewController {
    IBOutlet UITableView *table;
}

@end

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];
    table.center = location;
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [self touchesBegan:touches withEvent:event];
}