1

付属の例に基づいて AQGridView を実装しています。しかし、私はxibsを使用しています。例では、コードは次のとおりです。

 if ( plainCell == nil )
        {
            plainCell = [[[ImageDemoGridViewCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 200.0, 150.0)
                                                 reuseIdentifier: PlainCellIdentifier] autorelease];
            plainCell.selectionGlowColor = [UIColor blueColor];
        }

        plainCell.image = [UIImage imageNamed: [_imageNames objectAtIndex: index]];

        cell = plainCell;

    }

私のコードは次のようになります。

- (AQGridViewCell *) gridView: (AQGridView *)inGridView cellForItemAtIndex: (NSUInteger) index
  {


static NSString * FilledCellIdentifier = @"FilledCellIdentifier";

AQGridViewCell * cell = nil;

MagazineCell * filledCell = (MagazineCell *)[gridView dequeueReusableCellWithIdentifier: FilledCellIdentifier];

if ( filledCell == nil ) {


}

filledCell.edicaoLabel.text = [[data objectAtIndex:index] name];

cell = filledCell;

return ( cell );

}

InitWith CGRect の例ですが、xibs を使用する場合、どのようにセルを初期化しますか?

4

1 に答える 1

1

一般的に、XIBからビューをロードするときにビューを初期化することはありません。実際には、if(filledCell == nil)内で、UITableViewで実行するのと同じことを実行します(ただし、UITableViewCellの代わりにAQGridViewCellを使用します)。したがって、「GridCell.xib」にファイル所有者としてAQGridViewControllerがあり、tempCellがIB内のレイアウトされたGridCellにバインドされていて、識別子をfilledCellIdentiferに設定している場合は、次のようにすることができます。

[[NSBundle mainBundle] loadNibNamed:@"GridCell" owner:self options:nil]; 
filledCell = [self.tempCell autorelease];
于 2011-07-05T21:33:15.360 に答える