2014-10-06 39 views
0

我有一個非常奇怪的問題。在iOS8中,只有ipad 2(適用於所有設備上的iOS7和iOS8中的迷你),我擁有的簽名面板會在用戶將手指放在UIImageView上的時間越長時,使線條/繪製對象消失。用CoreGraphics繪製的iOS8線條隨着時間在UIImageView中褪色

谷歌搜索沒有提供任何想法嗎?這裏是用戶圖紙的繪圖代碼。

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
swiped = YES; 

UITouch *touch = [touches anyObject]; 
CGPoint currentPoint = [touch locationInView:self.view]; 
currentPoint.y -= 20; 

UIGraphicsBeginImageContext(self.view.frame.size); 
[_drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); 
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); 
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 0.0, 1.0); 
CGContextBeginPath(UIGraphicsGetCurrentContext()); 
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); 
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); 
CGContextStrokePath(UIGraphicsGetCurrentContext()); 
_drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

lastPoint = currentPoint; 

} 
+0

你試過用CGContextRef context = UIGraphicsGetCurrentContext();作爲一個變量..並使用上下文來代替UIGraphicsGetCurrentContext()..? – 2014-10-07 16:21:58

+0

有趣...是的,讓我試試 – JMD 2014-10-08 13:28:13

+0

我試過在iOS8中測試你的代碼,它的工作正常:/。 – 2014-10-08 14:19:00

回答

0

我一直有同樣的問題,只是發現原因。

我的UIImageView是在一個UITableViewCell中,並且UIImageView的自動識別掩碼被設置爲UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth。

事實證明,刪除UIViewAutoresizingFlexibleHeight,而是設置UIImageView的顯式高度,解決了這個問題。我懷疑這是由於iOS8中表格單元格的不同行爲,因爲我知道現在有一個自動調整大小功能(我沒有使用過,因爲我有自己的實現)。我懷疑這是與靈活的高度調整大小的面具,造成破壞,導致失真。

相關問題