2010-04-07 58 views
1

嗨,我是用下面這段代碼,讓用戶在我的應用程序在一個UIView組件「畫」的招牌:繪製的圖像完全是出於

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

我遇到的問題是,繪圖不僅在繪圖時與模擬器中的指針不一致,圖像超出了指定的UIView組件範圍,而且越來越小,聚焦越多,就像您在此圖像中看到的那樣: alt text http://dl.dropbox.com/u/1545603/iphone-signature-issues.png

並在幾行後顯示確切的邊界是我可以畫的地方: alt text http://dl.dropbox.com/u/1545603/iphone-signature-issues2.png

關於這裏發生了什麼的任何想法?

lastPoint.y被定義爲:lastPoint.y -= 20;

在地球上這裏發生了什麼任何想法?

回答

0

好了,想通了:

我可能會在以後張貼代碼,但是,UIView的借鑑設置爲:

signature.frame而應該signature.bounds所有屬性。

最後,刪除所有lastPoint.ycurrentPoint.y的定義。現在

,在這一點上,我會考慮使用變量來代替UIGraphicsGetCurrentContext()

0

也許,不是使用屏幕上的位置並繪製到白色視圖,而是使其相反,從而導致線條出現在白色視圖之外。

只是一個想法。對不起,但從我的iPhone這是我可以給的最好的答案。

順便說一句,我真的建議在設備上進行調試。我發現了大量的可用性缺陷,它對於衡量性能要好得多。

我迫不及待想看這個應用程序,給我發電子郵件的細節,我會在星期五看看。如果你願意,我有一個計算項目應用程序和一個網站,爲你進行beta/alpha測試!

+0

TY丹:)我的iPhone上試過了,這是相同的:( – bear 2010-04-07 20:09:19