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!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…