CGImageRef for UIImage rotates debugging my photos on iOS 4 in a simulator or device

I have a problem with some simple code. A photograph selected or taken with the camera rotates. At first I thought it was a setting in UIView, but this happens when I copy another UIImage passed to UIImage using CGImageRef. I did it like this because it was the easiest way to guarantee that I was using a copy. Correct this code if I messed up.

The code:

- (id)initWithImage:(UIImage *)image { if ((self = [super init]) && (image != nil)) { CGImageRef tmpImageRef = [image CGImage]; puzzle = [[UIImage alloc] initWithCGImage:tmpImageRef]; } return self; } 

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 line for creating CGIMageRef. Any help gratefully received. As I said, this does not happen in the simulator and only when I deploy the code on a real device. Please note that this post is used to say that the problem occurred only when debugging on devices, and not in the simulator. Since then, I copied the photo from the camera on my iphone 3gs to the simulator and the exact same problem. So if you have a 2048x1536 pic lying around you, you can duplicate this in a sim.

+4
source share
1 answer

UIImage has an orientation property that you ignore when retrieving CGImage from UIImage. You must do this:

 if (self = [super init]) { puzzle = image; } 
+2
source

Source: https://habr.com/ru/post/1315532/


All Articles