开发者社区> 问答> 正文

iphone中非正式用法ui_orientation

我看见了一段关于ui_orientation的代码如下:

UIImage *finalImage = [[UIImage alloc] initWithCGImage:cgimg
                      scale:2.0f orientation:ui_orientation([displayImage properties])];

很明显作用是读取CCImage的方向来适当创建UIImage。但是我在代码中使用出现了错误:
`
implicit declaration of function 'ui_orientation' is invalid in C99 。
`
不知道还要添加什么才能正常使用?
请高手帮忙。

来源:2012WWDC-lesson 510在25'16"

展开
收起
爵霸 2016-03-24 08:47:22 1870 0
1 条回答
写回答
取消 提交回答
  • 来自Session 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 session的全部pdf。然后保存在你的硬盘驱动器中。不会占很多空间的。这样你找哪期关于CATransaction 或者编造的函数的时候,可以使用Spotlight帮你找。有session的标题

    2019-07-17 19:11:49
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
使用TensorFlow搭建智能开发系统自劢生成App UI代码 立即下载
使用TensorFlow搭建智能开发系统自动生成App UI 立即下载
Fusion Design - 企业级UI解决方案揭秘 立即下载