I am trapped in a strange problem, I am making a keyboard extension, in which I need to draw highlight of key on touch. I am successfully able to do that, however strangely for some keys to the left top corner specially the keys Q and A, don't draw highlight everytime. Mainly my code looks like this..
- On
touchbegan
- Draw Highlight by calling[keysLayer setNeedsDisplay];
- On
touchEnd
- Remove Highlight by again calling[keysLayer setNeedsDisplay];
So basically, the drawRect
function doesn't get called everytime on those specific keys, everything else works fine, even setNeedsDisplay
gets called.
So, I am looking for help, that what can fail drawRect function to call, I want to know the list of reasons.
If anyone can help me.
Update
Adding code
In SuperView where the KeysLayer View has been added.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
keysLayer.drawHighlight=YES;
keysLayer.touchLocation=[touch locationInView:self];
[keysLayer setNeedsDisplay];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
keysLayer.drawHighlight=NO;
[keysLayer setNeedsDisplay];
}
Inside KeysLayer UIView class
- (void)setTouchLocation:(CGPoint)location{
self.touchLocation=location;
bezierPathForHighlight=[self createHighLightPath];//Creating simple path based on touch location.
}
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
if(!self.drawHighlight)
[bezierPathForHighlight removeAllPoints];
[bezierPathForHighlight stroke];
CGContextRestoreGState(context);
}
Update 2
So, I found the problem, its only occurring in my iPhone6 with iOS9.0. I verify this with this test application. Amazingly in this test application what I have found is there is a particular touch area where iOS doesn't call drawRect an iOS BUG?
See the attached image below, which explains where actually it happens. We have a problem, without a solution. Need Help.
Thanks.