我在WWDC视频上看到了这个ui_orientation糖果,用于此背景
UIImage *finalImage = [[UIImage alloc] initWithCGImage:cgimg scale:2.0f orientation:ui_orientation([displayImage properties])];
显然它会正确地读取CCImage的方向来创建UIImage,但在我的代码中使用它会产生这个错误:函数’ui_orientation’的隐式声明在C99中无效
你们知道我应该在源代码中包含什么标题来使这个功能起作用吗?
谢谢.
注意:WWDC 2012 – 第25课,25’16“……创建UIImage时
解决方法
这是来自会话422,他们在那里提供代码
Convert the orientation property to UIImageOrientation:
UIImageOrientation ui_orientation (NSDictionary* props) { int o = [[props valueForKey:(id)kCGImagePropertyOrientation] intValue]; UIImageOrientation map[] = { UIImageOrientationUp,UIImageOrientationUp,UIImageOrientationUpMirrored,UIImageOrientationDown,UIImageOrientationDownMirrored,UIImageOrientationLeftMirrored,UIImageOrientationRight,UIImageOrientationRightMirrored,UIImageOrientationLeft,}; return map[o]; }
这里也是一个方便的提示:从所有WWDC会话中下载所有PDF并将它们保存在硬盘上.他们不占用太多空间.这样,当您想要查找关于CATransaction的会话或(如此处)组成功能时,您可以使用Spotlight查找PDF,其中会话编号作为其标题.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。