iOS 多线程开发以及网络图片加载

NSDictionary *group=[[NSDictionary alloc]initWithObjectsAndKeys:indexPath,@"indexpath",cell,@"cell", nil];
[NSThread detachNewThreadSelector:@selector(loadLabelTableView:) toTarget:self withObject:group];

-(void)loadLabelTableView:(NSDictionary *)group
{
UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(50, 10, 200, 30)];
NSString *codeCharacter=[[m_listData objectAtIndex:[[group objectForKey:@"indexpath"][m_listData objectAtIndex:[[group objectForKey:@"indexpath"] row]] substringWithRange:NSMakeRange(3, 6)];
NSString *codeName=[[m_listData objectAtIndex:[[group objectForKey:@"indexpath"] row]] substringWithRange:NSMakeRange(10, 4)];
NSString *stockList=[NSString stringWithFormat:@"%@%@\t%@",codeCharacter,codeNumber,codeName];
label.text=stockList;
[[group objectForKey:@"cell"] addSubview:label];
}

网络图片加载方式:
-(void)loadImageCollectionView:(NSDictionary *)group
{
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 2, 70, 100)];
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:[[[listData objectAtIndex:[[group objectForKey:@"indexpath"] row]] objectForKey:@"images"] objectForKey:@"small"]]];
UIImage *img=[UIImage imageWithData:data];
imageView.ima substringWithRange:NSMakeRange(0, 2)];
NSString *codeNumber=[[m_listData objectAtIndex:[[group objectForKey:@"indexpath"][m_listData objectAtIndex:[[group objectForKey:@"indexpath"] row]] substringWithRange:NSMakeRange(10, 4)];
NSString *stockList=[NSString stringWithFormat:@"%@%@\t%@",codeCharacter,codeNumber,codeName];
label.text=stockList;
[[group objectForKey:@"cell"] addSubview:label];
}

网络图片加载方式:
-(void)loadImageCollectionView:(NSDictionary *)group
{
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 2, 70, 100)];
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:[[[listData objectAtIndex:[[group objectForKey:@"indexpath"] row]] objectForKey:@"images"] objectForKey:@"small"]]];
UIImage *img=[UIImage imageWithData:data];
imageView.image substringWithRange:NSMakeRange(3, 6)];
NSString *codeName=[[m_listData objectAtIndex:[[group objectForKey:@"indexpath"] row]] substringWithRange:NSMakeRange(10, 4)];
NSString *stockList=[NSString stringWithFormat:@"%@%@\t%@",codeCharacter,codeNumber,codeName];
label.text=stockList;
[[group objectForKey:@"cell"] addSubview:label];
}

网络图片加载方式:
-(void)loadImageCollectionView:(NSDictionary *)group
{
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 2, 70, 100)];
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:[[[listData objectAtIndex:[[group objectForKey:@"indexpath"] row]] objectForKey:@"images"] objectForKey:@"small"]]];
UIImage *img=[UIImage imageWithData:data];
imageView.image=img;
[[group objectForKey:@"cell"] addSubview:imageView];
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值