我正在开发一款iPhone应用程序。在那个应用程序中,我在滚动视图中有一些图像。要求是将这些图像拖放到视图和反之亦然。我可以从滚动视图拖动图像并将其放在self.view中。但是,当我尝试它反向意味着从self.view拖动那些图像并将其放到滚动视图它为我创建问题。我正在使用gesture.so我希望它将通过手势完成。
这是我的代码。
Y = 0;
for (int i=0; i<tileImgArray.count; i++)
{
imgScroll=[[UIImageView alloc]init];
imgScroll=[[dragImages objectAtIndex:i]valueForKey:@"Image"];
imgScroll.frame=CGRectMake(5, y, 40, 30);
imgScroll.userInteractionEnabled=YES;
[srlPuzzlePieces addSubview:imgScroll];
y=y+50;
}
NSMutableArray *draggableSubjects = [[NSMutableArray alloc] initWithArray:dragImages];
NSMutableArray *droppableAreas = [[NSMutableArray alloc] initWithObjects:play_view, nil];
_dragDropManager = [[DragDropManager alloc] initWithDragSubjects:draggableSubjects andDropAreas:droppableAreas];
_dragDropManager.dragImages=dragImages;
[draggableSubjects release];
[droppableAreas release];
[dragImages release];
panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:_dragDropManager action:@selector(dragging:)];
[[self view] addGestureRecognizer:panGesture];
[panGesture release];
srlPuzzlePieces.contentSize=CGSizeMake(0,y);
以下是我的拖放文件逻辑
由于