Silver Solution - Alternative


#1

I came up with a different solution than placing code inside of touchesBegan:withEvent: in TouchDrawView.m. The way I thought of the bug was that moveLine: was being called when you attempt to draw a new line after the menu is visible. So I fixed the bug inside of moveLine.

TouchDrawView.m

- (void)moveLine:(UIPanGestureRecognizer *)gr
{
    //if we haven't selected a line, we don't do anything
    if (![self selectedLine]) {
        return;
    }
    
    //Silver Challenge: Fix Bug
    //if we have selected a line but the menu is visible, don't move the line, deselect it
    //and cancel the menu
    UIMenuController *menu = [UIMenuController sharedMenuController];
    if ([self selectedLine] && menu.menuVisible) {
        [self setSelectedLine:nil];
        [menu setMenuVisible:NO animated:NO];
        return;
    }

   ...
}

#2

Good idea, however I would also include UIGestureRecognizerStateEnded in longPress: method to prevent the defect to appear if Panning is not used. Like this:

- (void)longPress:(UIGestureRecognizer *)gr
{
	if ([gr state] == UIGestureRecognizerStateBegan) {
		CGPoint point = [gr locationInView:self];
		[self setSelectedLine:[self lineAtPoint:point]];
		
		if ([self selectedLine]) {
			[linesInProcess removeAllObjects];
		} else if ([gr state] == UIGestureRecognizerStateEnded) {
			[self setSelectedLine:nil];
		}
		[self setNeedsDisplay];
	}
	//Silver challange
	if ([gr state] == UIGestureRecognizerStateEnded) {
		[self setSelectedLine:nil];
	}
}