1

我可以在iPhone地址簿中設置新聯繫人的縮略圖圖像,但是當該聯繫人撥打我的電話時,手機不顯示全屏版本。相反,它只在屏幕頂部顯示縮略圖版本,手機的屏幕保護程序位於後臺。有什麼特別的事情需要做,我忘了(見下面的代碼片段)?ABPersonSetImageData不會爲來電呼叫設置聯繫人的全尺寸圖像

而且,我沒有找到一個以前的職位,表明沒有以前的圖像可以保存爲聯繫人,但是這仍然沒有解決我的問題......

先謝謝了!

UIImage *profileImage = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:picImageUrl]]]; 

NSData *profileImageDataRef = UIImagePNGRepresentation(profileImage); 
ABPersonSetImageData(newPerson, (__bridge CFDataRef)profileImageDataRef, nil); 

回答

1

嘗試圖像剪切到全尺寸用下面的代碼

-(NSData *)dataFromImageData:(NSData *)imageData { 
    UIImage *image = [UIImage imageWithData:imageData]; 
    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { 
     UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, YES, 0.0); 
    } else { 
     UIGraphicsBeginImageContext([UIScreen mainScreen].bounds.size); 
    } 
    [image drawInRect:[UIScreen mainScreen].bounds]; 
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return UIImageJPEGRepresentation(newImage, 0); 
} 

然後將其保存

NSData *dataRef = [self dataFromImageData:imageData]; 
CFDataRef cfdata = CFDataCreate(NULL, [dataRef bytes], [dataRef length]); 
ABPersonSetImageData(aContact, cfdata, NULL);