手机
当前位置:查字典教程网 >编程开发 >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下载图片方法汇总】相关文章:

ajax 三种实现方法实例代码

iOS读取txt文件出现中文乱码的解决方法

iOS App中调用iPhone各种感应器的方法总结

详解iOS App中图片的线段涂鸦功能的添加方法

ios中图像进行压缩方法汇总

iOS仿擦玻璃效果的实现方法

改变iOS应用中UITableView的背景颜色与背景图片的方法

Objective-C实现冒泡排序算法的简单示例

objective-c中生成随机数的方法

IOS多线程编程的3种实现方法

精品推荐
分类导航