惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
Jina AI
Jina AI
博客园_首页
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
Forbes - Security
Forbes - Security
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
N
News | PayPal Newsroom
S
Security Archives - TechRepublic
量子位
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
C
Cisco Blogs
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
Scott Helme
Scott Helme
S
Securelist
Security Latest
Security Latest
爱范儿
爱范儿
TaoSecurity Blog
TaoSecurity Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
Intezer
L
LINUX DO - 最新话题
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Check Point Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
美团技术团队
Know Your Adversary
Know Your Adversary
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
月光博客
月光博客
T
Tailwind CSS Blog
Cloudbric
Cloudbric
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
K
Kaspersky official blog
D
DataBreaches.Net
博客园 - 【当耐特】
有赞技术团队
有赞技术团队

博客园 - K3

什么是URL,URI或URN? 软件设计思想的一些文章 (持续补充中) Mac OS X 上Lua的安装方法 Objective C - 3 - 实现一个计算器 Objective C - 2 - 随机数,可变字符串,字符串,SubString Objective C - 1 - 实现一个MessageBox.Show MySQL 存储过程,游标,临时表创建 List connected users–similar to task manager How to compose namespaces? Hide/Show running Console Calculate drive total/free/available space C# list installed softwares How to: Modify a Project System So That Projects Load in Multiple Versions of Visual Studio PS:WINRAR制作32位安装程序和64位安装程序选项 使用WINRAR来制作安装程序 impersonate a user VBScript - CUD registry key and value mysql script for dynamic running sql script XmlElement可以避免由XmlSerializer多余生成的代码
Objective C - 4 - 下载图片并且加载到View
K3 · 2014-05-29 · via 博客园 - K3
#import "LoadInternetImageViewController.h"

@interface LoadInternetImageViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation LoadInternetImageViewController


- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    [self loadImage];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)loadImage
{
    NSString *imageUrlString = @"http://d.hiphotos.baidu.com/image/pic/item/7af40ad162d9f2d3940b70e5abec8a136327cca6.jpg";

    UIImage *downloadedImage = [self downloadImage:imageUrlString];
    
    if(downloadedImage)
    {
        NSLog(@"Setting downloaded image to imageView.");
//        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        self.imageView.image = downloadedImage;
    }
    else
    {
        NSLog(@"Unable to find downloaded image.");
    }
}

-(UIImage *)downloadImage:(NSString *)imageUrlString
{
    NSData *imageStream = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrlString]];
    
    if (imageStream) {
    
        return [UIImage imageWithData:imageStream];
        
    }
    
    return nil;
}

@end

posted on 2014-05-29 22:23  K3  阅读(592)  评论()    收藏  举报