UIImageView加载网络图片,NSOperationQuene异步加载图片
来源:互联网 发布:unity3d 衣服模型 编辑:程序博客网 时间:2024/05/16 17:36
- #import "newDetailViewController.h"
- #import "Common.h"
- #import "newObject.h"
- #import "NetRequest.h"
- #import <UIKit/UIKitDefines.h>
- @interface newDetailViewController ()<UIWebViewDelegate>
- {
- UILabel *GWDetailTitleText;
- UILabel *GWDetailTitleText1;
- UITextView *GWDetailContentText;
- UIImageView *imageview;
- NSURL *url;
- UIView *opaqueview;
- UIActivityIndicatorView *activityIndicator;
- }
- @end
- @implementation newDetailViewController
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
- self.view.bounds = CGRectMake(0, -20, self.view.frame.size.width, self.view.frame.size.height );
- }
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [UIApplication sharedApplication].statusBarHidden = YES;
- [super viewDidLoad];
- //[self initView];
- }
- -(void)initView
- {
- UIButton *loginButton = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 40, 0, 40, 30)];
- [loginButton setTitle:@"返回" forState:UIControlStateNormal];
- loginButton.titleLabel.textColor =[UIColor blackColor];
- [loginButton addTarget:self action:@selector(backtofather) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:loginButton];
- GWDetailTitleText = [[UILabel alloc]initWithFrame:CGRectMake(10, 30, SCREEN_WIDTH - 20, 40)];
- GWDetailTitleText.textAlignment = NSTextAlignmentCenter;
- GWDetailTitleText.numberOfLines = 0;
- GWDetailTitleText.lineBreakMode = UILineBreakModeCharacterWrap;
- [self.view addSubview:GWDetailTitleText];
- GWDetailTitleText1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 70, SCREEN_WIDTH - 20, 20)];
- GWDetailTitleText1.textAlignment = NSTextAlignmentLeft;
- [self.view addSubview:GWDetailTitleText1];
- web = [[UIWebView alloc]initWithFrame:CGRectMake(10, 100, SCREEN_WIDTH - 20, self.view.bounds.origin.y + self.view.bounds.size.height - 110)];
- web.scalesPageToFit = YES;
- web.delegate = self;
- [[web layer] setCornerRadius:10];
- [web setClipsToBounds:YES];
- web.scalesPageToFit = NO;
- for (id subview in web.subviews)
- {
- if ([[subview class] isSubclassOfClass: [UIScrollView class]])
- {
- ((UIScrollView *)subview).bounces = NO;
- }
- }
- web.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:web];
- // GWDetailContentText = [[UITextView alloc]initWithFrame:CGRectMake(10, 100, SCREEN_WIDTH - 20, self.view.bounds.origin.y + self.view.bounds.size.height - 110)];
- // GWDetailContentText.layer.borderWidth = 1;
- // GWDetailContentText.editable = NO;
- // [self.view addSubview:GWDetailContentText];
- }
- -(void)setchoicedDate:(newObject *)myarray
- {
- [self initView];
- MyLog(@"%@ ", myarray );
- //MyLog(@"%@", myarray[0]);//[@"rel_title"]
- GWDetailTitleText.text = myarray.rel_title;
- NSString *date =[[NSString alloc]initWithString:myarray.rel_date];
- date = [date substringToIndex:10];
- NSString *mystring = [NSString stringWithFormat:@"发布人:%@ 日期:%@",myarray.rel_user,date];
- GWDetailTitleText1.text = mystring;
- MyLog(@"%@",myarray.rel_picpath);
- if (![myarray.rel_picpath isEqualToString:@"null"]) {
- url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",@"http://www.xf0573.com",myarray.rel_picpath]];
- imageview = [[UIImageView alloc]initWithFrame:CGRectMake(80, 0, 160, 120)];
- imageview.layer.masksToBounds = YES;
- imageview.layer.cornerRadius = 5.0f;
- [imageview setBackgroundColor:[UIColor grayColor]];
- imageview.image = [UIImage imageNamed:@"moren.png"];
- [web addSubview:imageview];
- opaqueview = [[ UIView alloc] initWithFrame: CGRectMake(0, 0, 160, 120)];
- activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame: CGRectMake( 0, 0, 160, 120)];
- [ opaqueview setBackgroundColor:[UIColor blackColor]];
- [ opaqueview setAlpha:0.6 ];
- [ imageview addSubview: opaqueview];
- [ opaqueview addSubview: activityIndicator];
- [ activityIndicator startAnimating ];
- opaqueview.hidden = NO ;
- web1 = [[UIWebView alloc]initWithFrame:CGRectMake(10, 120, SCREEN_WIDTH - 20, self.view.bounds.origin.y + self.view.bounds.size.height - web.frame.origin.y - 130)];
- web1.scalesPageToFit = YES;
- web1.delegate = self;
- [[web1 layer] setCornerRadius:10];
- [web1 setClipsToBounds:YES];
- web1.scalesPageToFit = NO;
- for (id subview in web1.subviews)
- {
- if ([[subview class] isSubclassOfClass: [UIScrollView class]])
- {
- ((UIScrollView *)subview).bounces = NO;
- }
- }
- web1.backgroundColor = [UIColor whiteColor];
- [web1 loadHTMLString:myarray.rel_content baseURL:nil];
- [web addSubview:web1];
- NSOperationQueue *operationQueue = [[NSOperationQueue alloc] init];
- NSInvocationOperation *op = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(downloadImage) object:nil];
- [operationQueue addOperation:op];
- //[web loadRequest:req];
- }else if ([myarray.rel_picpath isEqualToString:@"null"])
- {
- [web loadHTMLString:myarray.rel_content baseURL:nil];
- //GWDetailContentText.text = myarray.rel_content;
- }
- }
- - (void)downloadImage
- {
- UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
- imageview.image = image;
- [activityIndicator stopAnimating];
- opaqueview.hidden = YES ;
- }
- -(void)backtofather
- {
- [self dismissModalViewControllerAnimated:YES];
- }
- @end
0 0
- UIImageView加载网络图片,NSOperationQuene异步加载图片
- UIImageView异步加载网络图片
- UIImageView异步加载网络图片
- UIImageView异步加载网络图片
- uiimageview 异步加载图片
- UIImageView加载网络图片,NSOperationQueue来异步加载图片
- iOS-UIImageView加载网络下载的图片(异步+多线程)
- 异步加载网络图片
- 网络图片异步加载
- 异步加载网络图片
- 异步加载网络图片
- IOS 图片异步加载 - UIImageView(AFNetworking)
- Android 图片异步加载 加载网络图片
- UIImageView加载图片
- Android异步加载网络图片
- Android 异步加载网络图片
- Android网络图片异步加载
- Android异步加载网络图片
- 2015互联网校招总结
- 循环创建文件--php
- cocos2dx-3.x 修改默认物理引擎为Box2D
- @RequestMapping方法返回值为String类型
- DM365 IPNC软件架构详解
- UIImageView加载网络图片,NSOperationQuene异步加载图片
- 20141029 N2
- iOS 7系列译文:iOS7的多任务处理(转)
- 学生,倒更像是中文系的。我
- 【C/C++】计时函数比较
- TCP状态迁移,CLOSE_WAIT & FIN_WAIT2 的问题
- iOS 8系统占有率已过半
- Solr使用初探——SolrJ的使用
- 散尽,身形伟岸,微笑的