我正在使用以下代码循环遍历图像URL数组,并为返回的每个URL创建uiimageviews。话虽如此,所有图像在我的视图中都显示为彼此重叠。如何使每个图像以编程方式彼此相邻显示?例如。彼此右边大约10px?
NSMutableArray *photos = [self.filteredDataMeetUps valueForKey:@"photo_path"];
for (id object in photos) {
self.myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(37, 515, 40, 40)];
[self.myImageView sd_setImageWithURL:[NSURL URLWithString:object]];
[self.scrollView addSubview: self.myImageView];
self.myImageView.layer.cornerRadius = self.myImageView.frame.size.height /2;
self.myImageView.layer.borderColor = [[UIColor whiteColor] CGColor];
self.myImageView.layer.borderWidth = 0.0f;
self.myImageView.layer.masksToBounds = YES;
}
您总是在同一UIImageView(self.myImageView)中更改图像。您应该为每张照片创建一个新的UIImageView;
在您的代码中,您正在使用id object
而不是使用适当的类进行迭代:NSString *urlStr
;