它只是一個星期,這是進入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