国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

Objective C中遠程下載獲取圖片的詳細教程

2020-02-19 15:55:50
字體:
來源:轉載
供稿:網友

  今天小編給大家分享一篇Objective C中遠程下載獲取圖片的詳細教程,感興趣的朋友跟小編一起來了解一下吧!

  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/?id=%@", [[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中遠程下載獲取圖片的詳細教程了,希望大家能夠喜歡。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鹤峰县| 巨鹿县| 黄平县| 榆林市| 梓潼县| 长沙市| 柏乡县| 资中县| 东莞市| 伊宁市| 荥阳市| 土默特右旗| 凤凰县| 西华县| 泰和县| 兰西县| 兴城市| 呼玛县| 兴安县| 博罗县| 舞钢市| 昭苏县| 瑞安市| 宣威市| 和硕县| 巩义市| 宣城市| 老河口市| 水城县| 特克斯县| 清徐县| 沁阳市| 会昌县| 金乡县| 大理市| 饶河县| 丰顺县| 文山县| 德保县| 茂名市| 汶上县|