0
我用這個代碼從Facebook的個人資料得到的圖像,並顯示在UIImageView的檢索圖像iphone庫
// Get the profile image
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[result objectForKey:@"pic"]]]];
// Resize, crop the image to make sure it is square and renders
// well on Retina display
float ratio;
float delta;
float px = 100; // Double the pixels of the UIImageView (to render on Retina)
CGPoint offset;
CGSize size = image.size;
if (size.width > size.height) {
ratio = px/size.width;
delta = (ratio*size.width - ratio*size.height);
offset = CGPointMake(delta/2, 0);
} else {
ratio = px/size.height;
delta = (ratio*size.height - ratio*size.width);
offset = CGPointMake(0, delta/2);
}
CGRect clipRect = CGRectMake(-offset.x, -offset.y,
(ratio * size.width) + delta,
(ratio * size.height) + delta);
UIGraphicsBeginImageContext(CGSizeMake(px, px));
UIRectClip(clipRect);
[image drawInRect:clipRect];
UIImage *imgThumb = UIGraphicsGetImageFromCurrentImageContext();
[imgThumb retain];
imageFb=imgThumb;
[profilePhotoImageView setImage:imgThumb];
我想打一個按鈕,點擊後可以讓用戶通過圖像來改變形象iPhone的圖書館(他用iPhone拍攝的照片)。我不知道如何繼續,請幫助
有關更多控制,請參閱資產庫框架。它在很多方面都是「更現代的」,並提供了使用「UIImagePickerController」無法獲得的東西,但它不提供「UIViewController」級別的API,因此需要實施更多的工作。 – smparkes
我是初學者我只會使用UIImagePickerController xd – user567