+ Selection is highlighted when moved.

This commit is contained in:
Moritz Haarmann
2014-04-28 01:31:39 +02:00
parent fb271e8acb
commit ab2ec51204
4 changed files with 50 additions and 7 deletions

View File

@@ -161,7 +161,13 @@
#pragma mark - Gesture Handling
- (void)panned:(UIPanGestureRecognizer *)gestureRecognizer {
if ([self.editingControls selectedSegmentIndex] != UISegmentedControlNoSegment || self.isDrawing ){
BITImageAnnotation *annotationAtLocation = (BITImageAnnotation *)[self.view hitTest:[gestureRecognizer locationInView:self.view] withEvent:nil];
if (![annotationAtLocation isKindOfClass:[BITImageAnnotation class]]){
annotationAtLocation = nil;
}
if (([self.editingControls selectedSegmentIndex] != UISegmentedControlNoSegment || self.isDrawing) && !annotationAtLocation ){
if (gestureRecognizer.state == UIGestureRecognizerStateBegan){
self.currentAnnotation = [self annotationForCurrentMode];
[self.objects addObject:self.currentAnnotation];
@@ -192,11 +198,14 @@
} else {
if (gestureRecognizer.state == UIGestureRecognizerStateBegan){
// find and possibly move an existing annotation.
BITImageAnnotation *selectedAnnotation = (BITImageAnnotation *)[self.view hitTest:[gestureRecognizer locationInView:self.view] withEvent:nil];
if ([self.objects indexOfObject:selectedAnnotation] != NSNotFound){
self.currentAnnotation = selectedAnnotation;
if ([self.objects indexOfObject:annotationAtLocation] != NSNotFound){
self.currentAnnotation = annotationAtLocation;
[annotationAtLocation setSelected:YES];
}
} else if (gestureRecognizer.state == UIGestureRecognizerStateChanged && self.currentAnnotation){
CGPoint delta = [gestureRecognizer translationInView:self.view];
@@ -213,6 +222,8 @@
} else {
self.currentAnnotation = nil;
[annotationAtLocation setSelected:NO];
}
}
}