I have a problem with some simple code. The photo's, either picked or taken with the camera, are rotated. At first I thought it was a setting in the UIView but it happens when I copy the passed in UIImage to another UIImage using CGImageRef. I did it this way as it was the easiest way to ensure I was using a copy. Correct this code if I've screwed up please.
The code:
- (id)initWithImage:(UIImage *)image {
if ((self = [super init]) && (image != nil)) {
CGImageRef tmpImageRef = [image CGImage];
puzzle = [[UIImage alloc] initWithCGImage:tmpImageRef];
}
return self;
}
The debugger:
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys001
Loading program into debugger…
sharedlibrary apply-load-rules all
Program loaded.
target remote-mobile /tmp/.XcodeGDBRemote-25694-49
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
run
Running…
[Switching to thread 11523]
[Switching to thread 11523]
Re-enabling shared library breakpoint 1
Re-enabling shared library breakpoint 2
continue
2010-07-13 15:09:17.159 Golovomka[693:307] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
2010-07-13 15:09:17.172 Golovomka[693:307] Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate
Current language: auto; currently objective-c
(gdb) print (CGSize)[image size]
$1 = {
width = 1536,
height = 2048
}
(gdb) n
28 puzzle = [[UIImage alloc] initWithCGImage:tmpImageRef];
(gdb)
31 return self;
(gdb) print (CGSize)[puzzle size]
$2 = {
width = 2048,
height = 1536
}
(gdb)
The first print is on the CGIMageRef instantiation line. Any help gratefully received. As I said, this does not happen in the simulator and only when I deploy the code to a real device. Please note this post used to say that the problem only occurred debugging on devices and not in the simulator. I have since copied a photo taken with the camera on my iphone 3gs to the simulator and exactly the same problem occurs. So if you have a 2048x1536 pic lying around you should be able to duplicate this in the sim.