【发布时间】:2014-07-19 05:51:10
【问题描述】:
我确实为 Url 获取图像。然后在 SCrollView 上显示。我的代码是这样的
NSMutableArray *al=[NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
for (NSDictionary *diction in al)
{
NSString *geting =[diction valueForKey:@"dealimage"];
NSLog(@"dealimage is %@",geting);
NSData *getdata=[[NSData alloc]initWithData:[NSData dataFromBase64String:geting]];
NSLog(@"good day %@",getdata);
dataimages=[UIImage imageWithData:getdata];
NSLog(@"dataimages %@",dataimages);
[imagesarray addObject:dataimages];
}
scrollView=[[UIScrollView alloc]init];
scrollView.delegate = self;
scrollView.scrollEnabled = YES;
int scrollWidth = 100;
scrollView.contentSize = CGSizeMake(scrollWidth,100);
scrollView.frame=CGRectMake(0, 0, 320, 100);
scrollView.backgroundColor=[UIColor yellowColor];
[self.view addSubview:scrollView];
int xOffset = 0;
imageView.image = [UIImage imageNamed:[imagesName objectAtIndex:0]];
for(int index=0; index < [imagesName count]; index++)
{
UIImageView *img = [[UIImageView alloc] init];
img.bounds = CGRectMake(10, 10, 50, 50);
img.frame = CGRectMake(5+xOffset, 0, 160, 110);
NSLog(@"image: %@",[imagesName objectAtIndex:index]);
img.image = [UIImage imageNamed:[imagesName objectAtIndex:index]];
[images insertObject:img atIndex:index];
scrollView.contentSize = CGSizeMake(scrollWidth+xOffset,110);
[scrollView addSubview:[images objectAtIndex:index]];
xOffset += 170;
}
我的问题是 ScrollView 是显示但没有添加图像所以请告诉我我的代码有什么问题
现在我需要这样的
我知道如何获取 Url 的图像。现在我需要显示图像 Horizontal ScrollView 所以请告诉我有关图像的任何想法。
【问题讨论】:
-
你为什么对你得到的每一个答案都评论“请看一次我的问题”?
-
@AlexanderFarber 对不起,我的意图是我改变了问题,所以开玩笑地暗示了所有人
标签: ios objective-c uiscrollview uiimageview