0

AQGridView を使用して、約 21 項目の画像ギャラリーを作成しています。アプリのロゴと名前を含むビューをこのリスト/スクロールビューの一番上に追加して、ユーザーがそれを見るようにしたいのですが、スクロールして画像を見ると、名前とロゴのあるビューが一緒にスクロールします。誰かが前にこのようなものを実装しましたか?

@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;
}

シミュレーターのスクリーンショットは次のとおりです。

ここに画像の説明を入力

4

1 に答える 1

1

はい。で簡単にこれを行うことができますaddSubview:AQGridViewインスタンスでUIImageView、サブビューとしてを追加します。は、で使用できるAQGridViewサブクラス化されたものにすぎません。UIScrollViewaddSubview:

....
AQGridView *_grid;
....
UIImageView *logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo.png"]];
[logo setFrame:CGRectMake(0,0,logo.frame.size.width,logo.frame.size.height)]; // Set the Frame's position on where you want it in the grid.
[_grid addSubview:logo];

お役に立てれば。

編集AQGridView:すべての画像がロゴと重なるように、最初のサブビューとしてロゴを追加することを反映するように回答を編集します。を使用する代わりに[_grid addSubview:logo]、これらがの使用であると仮定しUIImageViewます。

[_grid insertSubview:logo belowSubview:(UIImageView*)[_grid.subviews objectAtIndex:0]];

mkralによる編集

skramバージョンは機能しますが、私の目的には、gridViewHeaderが最適なオプションであることに言及したいと思います。コードを参照してください。

UIImageView *logo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"paramythLogoTest.png"]];
[logo setFrame:CGRectMake(0,0,logo.frame.size.width,logo.frame.size.height)]; 
[gridView setGridHeaderView:logo]; 
于 2012-06-14T16:22:34.710 に答える