手机
当前位置:查字典教程网 >编程开发 >IOS开发 >Objective C从远程url下载图片方法汇总
Objective C从远程url下载图片方法汇总
摘要:ObjectiveC从远程url下载图片-(UIImage*)getImageFromURL:(NSString*)theURL{UIIma...

Objective C从远程url下载图片

- (UIImage *) getImageFromURL: (NSString *)theURL { UIImage *theImage = NULL; NSString *imageFileName = [BT_strings getFileNameFromURL:theURL]; NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:theURL]]; theImage = [[UIImage alloc] initWithData:imageData]; [BT_fileManager saveImageToFile:theImage fileName:imageFileName]; return theImage; }

objective C从远程地址获取图片并修改尺寸

NSString* imageURL = [NSString stringWithFormat: @"http://theimageurl.com/", [[resultsEntries objectAtIndex:0] objectForKey: @"image_large"]]; NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imageURL]]; UIImage* image = [[UIImage alloc] initWithData:imageData]; // resize image CGSize newSize = CGSizeMake(100, 100); UIGraphicsBeginImageContext( newSize );// a CGSize that has the size you want [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; //image is the original UIImage UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); imageHeight = image.size.height; [imageMain setImage:newImage]; [imageData release]; [image release];

以上所述就是本文的全部内容了,希望大家能够喜欢。

【Objective C从远程url下载图片方法汇总】相关文章:

ios下移动文件方法汇总

浅析Objective-C的程序结构及面向对象的编程方式

Objective-C封装字符串存储操作示例

Objective-C中字符串的拼接方法小结

iOS实现图片轮播效果

Objective-C 代码与Javascript 代码相互调用实例

理解Objective-C的变量以及面相对象的继承特性

详解iOS开发中UIPickerView控件的使用方法

iOS开发中用imageIO渐进加载图片及获取exif的方法

IOS绘制虚线的方法总结

精品推荐
分类导航