- (void)viewDidLoad
{
[super viewDidLoad];
_urls = @[@"http://ww4.sinaimg.cn/thumbnail/7f8c1087gw1e9g06pc68ug20ag05y4qq.gif", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr0nly5j20pf0gygo6.jpg", @"http://ww4.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr1d0vyj20pf0gytcj.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr1xydcj20gy0o9q6s.jpg", @"http://ww2.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr2n1jjj20gy0o9tcc.jpg", @"http://ww2.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr39ht9j20gy0o6q74.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr3xvtlj20gy0obadv.jpg", @"http://ww4.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr4nndfj20gy0o9q6i.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr57tn9j20gy0obn0f.jpg"];
UIImage *placeholder = [UIImage imageNamed:@"timeline_image_loading.png"];
CGFloat width = 70;
CGFloat height = 70;
CGFloat margin = 20;
CGFloat startX = (self.view.frame.size.width - 3 * width - 2 * margin) * 0.5;
CGFloat startY = 50;
for (int i = 0; i<9; i++) {
UIImageView *imageView = [[UIImageView alloc] init];
[self.view addSubview:imageView];
int row = i/3;
int column = i%3;
CGFloat x = startX + column * (width + margin);
CGFloat y = startY + row * (height + margin);
imageView.frame = CGRectMake(x, y, width, height);
[imageView setImageURLStr:_urls[i] placeholder:placeholder];
imageView.tag = i;
imageView.userInteractionEnabled = YES;
[imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImage:)]];
imageView.clipsToBounds = YES;
imageView.contentMode = UIViewContentModeScaleAspectFill;
}
}
- (void)tapImage:(UITapGestureRecognizer *)tap
{
int count = _urls.count;
NSMutableArray *photos = [NSMutableArray arrayWithCapacity:count];
for (int i = 0; i