4

我的所有代表都被连接起来并要求一个垂直布局对象。在水平模式下,由于某种原因,唯一调用的委托是numberofcellsincollectionview(返回正确的数字) -cellforitematindexpath除非我增加 collectionview 框架的大小,否则不会调用。当它足够大时cellforitematindexpath被调用。这种奇怪的行为仅在 collectionview 布局处于水平模式时才会发生。在垂直模式下没有出现这种行为。(这个奇怪的行为也只开始于 iOS7 - 不知道是否有连接)

横向布局代码

-(UICollectionViewFlowLayout *)getFilmStripLayout
{

    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];

    [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
    [flowLayout setSectionInset:UIEdgeInsetsMake(0, 0, 0, 0)];
    CGSize s = CGSizeMake(self.frame.size.height,self.frame.size.height);

    [flowLayout setItemSize:s];
    return flowLayout;
}

包含视图的视图控制器

-(UIThumbnailGalleryView *)gallery
{
    if (_gallery == nil)
    {

       CGRect r = CGRectInset(self.filmStripRect, 0, -20); // started with inset 0,0 , increased the size and then the delegates are called. 
        _gallery = [[UIThumbnailGalleryView alloc] init2WithFrame:r]; // custom initializer testing layouts
        [_gallery setBackgroundColor:[UIColor clearColor]];
        [_gallery setBackgroundColor:[UIColor purpleColor]]; // setting colors in order to see the placement
        _gallery.layer.borderColor = [UIColor orangeColor].CGColor;
        _gallery.layer.borderWidth = 3;
        _gallery.dataSource = self;
        _gallery.delegate = self;
        [_gallery setInToggleMode:YES];
    }
    return _gallery;
}
4

0 回答 0