//
Zbmainviewcontroller.m
TestProject
//
Created by Zhang Xianxin 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 *[email protected] "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
Inter-thread communication