After successfully acquiring a picture from the iPhone camera on iOS 4.1, you can use the key
@"UIImagePickerControllerMediaMetadata"
to return information about the picture. One of the keys in that dictionary is
@"Orientation"
From my experimentation, Portrait and Upside down are 6 and 8 respectively, and the landscapes are 1 and 3. Look at this code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSDictionary *metaData = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
id orientation = [metaData objectForKey:@"Orientation"];
NSLog(@"Class: %@",[orientation class]);
The NSLog says "Class: NSCFNumber"
I need to compare this object's value to determine how to proceed. Landscape is 1 or 3, portrait is 6 or 8. I'm not sure what to type orientation as or what to call on it. NSNumber and NSInteger always tells me I'm making integers from pointers without casts.
Thanks for your time!
This is telling you that orientation is a instance of NSNumber
. Technically, NSCFNumber
is a private subclass of NSNumber
, but that is an implementation detail which you don't have to worry about. To get the integer value you would call
[orientation integerValue]
NSNumber
is a class cluster. NSCFNumber
is a concrete, "private" implementation of a class in that cluster. Just use the returned value like you would an NSNumber
object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With