它只是一个星期,这是进入ios偏移,并面临一些问题,我不能用gridview格式显示滚动视图中的图像...我不知道如何设置框架大小以适当的gridview格式显示图像..如何在ios中的uiscrollview中以gridview格式显示图像?
这里是我的代码
,在滚动视图
for(int i=1;i<6;i++)
{
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(x+0, 0, 320, 460)];
[image setImage:[UIImage imageNamed:[NSString stringWithFormat:@"e1%d.png",i]]];
[scr addSubview:image];
x+=320;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
tapGesture.numberOfTapsRequired = 1;
tapGesture.delegate = self;
image.userInteractionEnabled = YES;
[image addGestureRecognizer:tapGesture];
}
scr.pagingEnabled=YES;
scr.contentSize = CGSizeMake(320*5, 300);
[self.view addSubview:scr];
加5张图片,但所有5个图片显示在一个水平线上,但我想在每行2倍的图像显示。
改为使用UICollectionView。 – DrummerB 2013-03-20 09:31:14
实际上它只是一个星期我进入这个...所以如果你可以指导我与上述代码的一些变化,那么它将有所帮助.. – 2013-03-20 09:34:18
我现在没有时间,现在,对不起,这就是为什么我没有发布完整的答案,也许别人可以。查看UICollectionView上的WWDC视频:https://developer.apple.com/videos/wwdc/2012/?id = 205 – DrummerB 2013-03-20 09:38:13