0
我正在使用AQGridView創建一個包含約21個項目的圖像庫。我想將包含應用徽標和名稱的視圖添加到此列表/滾動視圖的頂部,以便用戶可以看到它,但當他們滾動查看圖像時,帶有名稱和徽標的視圖會隨之滾動。有沒有人實施過這樣的事情?將視圖添加到AQGridView的頂部ScrollView
感謝@skram我能夠添加徽標,但現在圖像阻止了第一行圖像。
這裏就是我定義的標識,並將其添加到GridView:
self.gridView = [[AQGridView alloc] initWithFrame:CGRectMake(0, 0, 320, 367)];
UIImageView *logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"paramythLogoTest.png"]];
[logo setFrame:CGRectMake(0,0,logo.frame.size.width,logo.frame.size.height)];
[gridView addSubview:logo];
self.gridView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
self.gridView.autoresizesSubviews = YES;
self.gridView.delegate = self;
self.gridView.dataSource = self;
[self.view addSubview:gridView];
[self.gridView reloadData];
圖像並在這裏裝:
- (AQGridViewCell *) gridView: (AQGridView *) aGridView cellForItemAtIndex: (NSUInteger) index
{
static NSString * PlainCellIdentifier = @"PlainCellIdentifier";
GridViewCell * cell = (GridViewCell *)[aGridView dequeueReusableCellWithIdentifier:@"PlainCellIdentifier"];
if (cell == nil)
{
cell = [[GridViewCell alloc] initWithFrame: CGRectMake(3.333, 3.333, 100, 100)
reuseIdentifier: PlainCellIdentifier];
}
NSString *stringURL = [[featuredStories objectAtIndex:index] objectAtIndex:1];
NSURL *url = [NSURL URLWithString:stringURL];
[cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"example0.png"]];
cell.storyID = [[featuredStories objectAtIndex:index] objectAtIndex:0];\
return cell;
}
這裏是模擬器的截圖:
好吧,它的工作原理,但它覆蓋的圖像。你知道我需要設置偏移量嗎? – mkral
你可以使用'insertSubview:belowSubview'。這將做的是添加您的標誌作爲圖層中的第一個對象。之後的所有內容都將添加到上面的圖層上:'[_grid insertSubview:logo belowSubview:(UIImageView *)[_ grid.subviews objectAtIndex:0]];假設它是一個'UIImageView' – skram
我在你的例子中有點困惑你不是說要在同一個標識imageview下面插入標識imageview? – mkral