程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> ios-蘋果中非正式用法ui_orientation

ios-蘋果中非正式用法ui_orientation

編輯:編程綜合問答
蘋果中非正式用法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"

最佳回答:


來自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的標題

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved