码迷,mamicode.com
首页 > 编程语言 > 详细

线程间的通信

时间:2014-12-09 01:45:07      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:http   io   sp   for   strong   on   2014   log   bs   

//

//  ZBMainViewController.m

//  TestProject

//

//  Created by 张先森 on 14/12/5.

//  Copyright (c) 2014年 zhibin. All rights reserved.

//

 

#import "ZBMainViewController.h"

 

@interface ZBMainViewController ()

@property(nonatomic,strong)UIImageView *imageview;

 

 

@end

 

@implementation ZBMainViewController

 

 

 

 bool isopen=NO;

 

 

- (void)viewDidLoad {

    [super viewDidLoad];

    UIImageView  *imageview=[[UIImageView alloc] init];

 

    self.imageview=imageview;

    

    [self.view addSubview:imageview];

    

    [self InitControls];

}

 

-(void)InitControls{

    [self performSelectorInBackground:@selector(dowland) withObject:nil];

}

 

-(void)dowland{

    NSString *url=@"http://www.smzdm.com/resources/public/img/logo.png";

    

    

    NSURL *myurl=[NSURL URLWithString:url];

    

    

    NSData *data=[NSData dataWithContentsOfURL:myurl];

    

    UIImage *image=[UIImage imageWithData:data];

    

    [self performSelectorOnMainThread:@selector(detaildata:) withObject:image waitUntilDone:NO];

    

   

    [self.imageview performSelector:@selector(setImage:) onThread:[NSThread mainThread] withObject:image waitUntilDone:NO];

    

    

         [self.imageview performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];

 

}

-(void)detaildata:(UIImage *)image{

        self.imageview.image=image;

    

      [self.imageview sizeToFit];

  

 

}

 

 

 

 

 

 

 

@end

 

线程间的通信

标签:http   io   sp   for   strong   on   2014   log   bs   

原文地址:http://www.cnblogs.com/zhibin/p/4152311.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!