在iOS 4.1上成功从iPhone相机获取图片后,您可以使用该密钥
@"UIImagePickerControllerMediaMetadata"
Run Code Online (Sandbox Code Playgroud)
返回有关图片的信息.该词典中的一个关键是
@"Orientation"
Run Code Online (Sandbox Code Playgroud)
从我的实验来看,肖像和颠倒分别是6和8,景观是1和3.看看这段代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSDictionary *metaData = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
id orientation = [metaData objectForKey:@"Orientation"];
NSLog(@"Class: %@",[orientation class]);
Run Code Online (Sandbox Code Playgroud)
NSLog说"Class:NSCFNumber"
我需要比较这个对象的值来确定如何继续.横向是1或3,纵向是6或8.我不确定要键入方向或调用什么.NSNumber和NSInteger总是告诉我,我正在使用没有强制转换的指针制作整数.
谢谢你的时间!