iPhone SDK: Image Capture Landscape Mode
I want to allow my users to draw a picture on their screen in landscape mode.
Upon button being pressed, that image should be stored locally on the device.
I am using this code example below which works vertically http://www.ipodtouchfans.com/forums/showthread.php?t=132024
My problem is that I'm trying to adjust the code for landscape mode with a smaller drawing area but it's not working. I am not sure why?
There seems to be three areas that involve the bounds that the user may draw in. I've tried changing the size but that doesn't seem to wor开发者_如何学Pythonk. What am I missing?
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)];
...
}
If you are intended to have only landscape view. Then add the following code to the example:-
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
else
return NO;
}
and go to project properties and set device orientation to Landscape Left and Landscape Right
Hope this will solve your problem.
I am also using that code for drawing and when I am switching to landscape mode I am giving again frame for our drawimage. Or the view you are using for drawing. If you are giving your UIView
class from xib class then its better to set landscape mode frame from there.
And yes, one thing if make some drawing in portrait mode and switching to landscape mode then you have to adjust its lastpoint and currentpoints as per your area.
精彩评论