面試題

  1. 什么是大端和小端?
  • 大端模式:高位字節(jié)排放在內(nèi)存的低地址端,低位字節(jié)排放在內(nèi)存的高地址段。
  • 小端模式:低位字節(jié)排放在內(nèi)存的低地址端,高位字節(jié)排放在內(nèi)存的高地址端。
  1. 一個NSObject對象占用多少內(nèi)存
  • 系統(tǒng)分配了16個字節(jié)給NSObject對象(通過malloc_size函數(shù)獲得)
  • 但NSObject對象內(nèi)部只使用了8個字節(jié)的空間(64bit環(huán)境下)
 NSObject *obj = [[NSObject alloc] init];
 NSLog(@"%zd", class_getInstanceSize([NSObject class]));
 NSLog(@"%zd", malloc_size((__bridge void *)obj));
  1. ImageIO學習
- (void)viewDidLoad {
    [super viewDidLoad];

    
    UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(60, 120, [UIScreen mainScreen].bounds.size.width - 120, 160)];
    [self.view addSubview:iv];
    
//
//    UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"11.jpeg" ofType:nil]];
//    NSData *data = UIImageJPEGRepresentation(image, 1.0);
//    SDImageFormat type = [NSData sd_imageFormatForImageData:data];
//    NSLog(@"%zd", type);
//
//    NSString *typeStr = (NSString *)[NSData sd_UTTypeFromImageFormat:type];
//    NSLog(@"%@", typeStr);
    
//    CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);

    NSString *path = [[NSBundle mainBundle] pathForResource:@"show.gif" ofType:nil];
    NSURL *url = [NSURL fileURLWithPath:path];

    CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)url, NULL);

    long count = CGImageSourceGetCount(source);
    NSLog(@"圖片個數(shù)%ld", count);
    //獲取第幾張圖片
    CGImageRef firstImage = CGImageSourceCreateImageAtIndex(source, 23, NULL);

    NSArray *arr = CFBridgingRelease(CGImageSourceCopyTypeIdentifiers());
    NSLog(@"支持的類型\n%@", arr);

    NSString *type = CFBridgingRelease(CGImageSourceGetType(source));
    NSLog(@"所加載圖片的類型為:%@", type);

    // 獲取某一幀圖片的縮略圖
    CGImageRef thumbnailImage = CGImageSourceCreateThumbnailAtIndex(source, 0, NULL);
    NSLog(@"%@", thumbnailImage);
    
    CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
    
    NSInteger orientationValue = 1;
    CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight);
    // 圖片的高度
    if (val) CFNumberGetValue(val, kCFNumberLongType, &_height);
    val = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth);
    // 圖片的寬度
    if (val) CFNumberGetValue(val, kCFNumberLongType, &_width);
    val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation);
    // 圖片的方向
    if (val) CFNumberGetValue(val, kCFNumberNSIntegerType, &orientationValue);
    
    CFRelease(source);
    _orientation = (CGImagePropertyOrientation)orientationValue;
    
    
    iv.image = [UIImage imageWithCGImage:thumbnailImage];
}
最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • 推薦閱讀:iOS開發(fā)——2019 最新 BAT面試題合集(持續(xù)更新中) 史上最全的iOS面試題及答案 iOS面試小...
    iOS開發(fā)之家閱讀 1,721評論 1 15
  • 多線程、特別是NSOperation 和 GCD 的內(nèi)部原理。運行時機制的原理和運用場景。SDWebImage的原...
    LZM輪回閱讀 2,124評論 0 12
  • 最全的iOS面試題及答案 iOS面試小貼士 ———————————————回答好下面的足夠了-----------...
    zweic閱讀 2,803評論 0 73
  • 史上最全的iOS面試題及答案 iOS面試小貼士———————————————回答好下面的足夠了----------...
    Style_偉閱讀 2,575評論 0 35
  • iOS面試小貼士 ———————————————回答好下面的足夠了------------------------...
    不言不愛閱讀 2,251評論 0 7

友情鏈接更多精彩內(nèi)容