gdavis / FGallery-iPhone

Objective-C based gallery for iPhones
583 stars 144 forks source link

The caption height is incorrect #37

Open mdikov opened 11 years ago

mdikov commented 11 years ago

It looks like on some occasions the caption height will not be calculated properly. A simpler and safer way to calculate the size of the caption is to use [_caption sizeThatFits...]

in update caption I use this and all works fine:

           float captionWidth = _container.frame.size.width-kCaptionPadding*2;

            _caption.numberOfLines = 0;
            _caption.text = caption;
            CGSize adjustedSize = [_caption sizeThatFits:CGSizeMake(captionWidth, _container.frame.size.height)];

            NSInteger containerHeight = adjustedSize.height+kCaptionPadding*2;
            _captionContainer.frame = CGRectMake(0, -containerHeight, _container.frame.size.width, containerHeight );
            _caption.frame = CGRectMake(kCaptionPadding, kCaptionPadding, captionWidth, adjustedSize.height );

            // show caption bar
            _captionContainer.hidden = NO;