【发布时间】:2016-01-18 11:22:21
【问题描述】:
我有一个产品详细信息列表作为 NSMutableArray 中的对象和产品图像列表作为图库,我需要在单击缩略图时加载完整图像。为此,我设置标签并在点击特定图像时获得准确的标签值。问题是我无法获取数组对象。我使用手动数字进行测试,数组完美地返回对象。我在这里做错了什么?
标签设置代码:
for(int index=0; index < [self.sliderImages count]; index++)
{
UIImageView *imageView = [[UIImageView alloc]init];
imageView.frame = CGRectMake(xOffset, 0, 100, scrollHeight);
imageView.tag = index;
Products *product = [self.sliderImages objectAtIndex:index];
NSLog(@"product name %@",product.name);
NSString *imageUrl = [NSString stringWithFormat:@"%@",product.imagePath];
}
点击手势识别方法:
- (void) tapGesture:(id)sender
{
//handle Tap...
UIImageView *tmp = (UIImageView *)[sender view];
int tm = (int)(tmp.tag);
NSLog(@"self.sliderImages%@",[self.sliderImages objectAtIndex:tm]);
Products *product = [self.sliderImages objectAtIndex:tm];
NSLog(@"product%@",product);
NSLog(@"product ges %@,, %@",product.name,product.imagePath);
NSString *imageUrl = [NSString stringWithFormat:@"%@",product.imagePath];
NSLog(@"full image path :: %@",imageUrl);
[self loadFullImage:tm];
}
【问题讨论】:
-
请贴出你试过的代码
-
请检查mu code - (void) tapGesture:(id)sender { //handle Tap... UIImageView *tmp = (UIImageView *)[sender view]; int tm = (int)(tmp.tag); NSLog(@"self.sliderImages%@",[self.sliderImages objectAtIndex:tm]);产品 *product = [self.sliderImages objectAtIndex:tm]; NSLog(@"product%@",product); NSLog(@"product ges %@,, %@",product.name,product.imagePath); NSString *imageUrl = [NSString stringWithFormat:@"%@",product.imagePath]; NSLog(@"图片全路径:: %@",imageUrl); [自加载完整图像:tm]; }
-
请添加标签设置代码。
-
for(int index=0; index
-
@user1591698 请在您的问题中添加您的代码并格式化。这样其他人就可以轻松阅读,并且可以尽快给予。
标签: ios tags nsmutablearray