2010-09-10 97 views
6

我想允許我的用戶在橫向模式下在屏幕上繪製圖片。iPhone SDK:圖像捕捉橫向模式

按下按鈕後,該圖像應該本地存儲在設備上。

我使用此代碼示例,低於該作品垂直 http://www.ipodtouchfans.com/forums/showthread.php?t=132024

我的問題是,我試圖調整與更小的繪圖區域橫向模式下的代碼,但它不工作。我不知道爲什麼?

似乎有三個方面涉及到用戶可能繪製的邊界。我試圖改變大小,但似乎並不奏效。我錯過了什麼?

Orignally: 

viewDidLoad: 
drawImage = [[UIImageView alloc] initWithImage:nil]; 
drawImage.frame = self.view.frame; 

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 

UIGraphicsBeginImageContext(self.view.frame.size); 
    [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
... 
} 

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 

UIGraphicsBeginImageContext(self.view.frame.size); 
     [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
... 
} 
+1

目前還不清楚你在問什麼。用戶是否在屏幕上繪圖或者捕獲圖像並將其存儲在其中?您的代碼以何種方式「不能工作」?那就是:(a)你預期會發生什麼?和(b)發生了什麼? – Olie 2011-06-28 15:37:18

+0

您是否可以用較小的繪圖區域顯示用於調整橫向模式的代碼部分?也許你沒有正確地做到這一點。 – fuzz 2011-09-08 06:58:00

+0

「drawImage.frame = self.view.frame;」 - >你確定這就是你想要做的?你通常設置child.frame = self.view.bounds – Geoffroy 2011-10-02 20:29:32

回答

0

如果您打算只有橫向視圖。然後將下面的代碼添加到例如: -

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
     return YES; 
    else 
     return NO; 
} 

,並轉到項目屬性,設置設備定向景觀左景觀右

希望這將解決您的問題。

-1

我也在使用該代碼進行繪圖,當我切換到橫向模式時,我再次給出了drawimage框架。或者您正在用於繪圖的視圖。如果你正在給你的xib類的UIView類,那麼最好從那裏設置橫向模式框架。

是的,有一件事,如果在縱向模式下進行一些繪圖並切換到橫向模式,那麼您必須根據您的區域調整其最後一個點和當前點。

相關問題