iPhone SDK:图像捕捉横向模式

but*_*boy 6 iphone

我希望允许我的用户在横向模式下在屏幕上绘制图片.

按下按钮后,该图像应本地存储在设备上.

我正在使用下面的代码示例垂直工作 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)];
...
}
Run Code Online (Sandbox Code Playgroud)

小智 0

如果您只想欣赏风景。然后将以下代码添加到示例中:-

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

并转到项目属性并将设备方向设置为横向左横向右

希望这能解决您的问题。