2010-09-10 100 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类,那么最好从那里设置横向模式框架。

是的,有一件事,如果在纵向模式下进行一些绘图并切换到横向模式,那么您必须根据您的区域调整其最后一个点和当前点。

相关问题