zoukankan      html  css  js  c++  java
  • 线程间的通信

    //

    //  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缓存
    深入理解vertical-align
    WebSocket
    mongodb 语法小结
    鸡肋工具-Oracle建表工具
    Ajax 实现导出文件-支持批量
    Springboot 热部署
    RabbitMq(7)消息延时推送
    linux常用符号命令
    linux常用命令之文档
  • 原文地址:https://www.cnblogs.com/zhibin/p/4152311.html
Copyright © 2011-2022 走看看