iosthree20addsubviewttphotoviewcontroller

adding subviews to TTPhotoview of TTPhotoViewController


I am using this library https://github.com/facebook/three20.

Looking at other samples & suggestions I have subclass TTPhotoview.

I would like to display additional labels or details regarding current photo. I want to place those details in left or top corner.

I am able to place and display UILabel in SubView and display it, however when user double tap to zoom the image, those label moves along with that. I want those details to still display but remain in same position after zooming as well.

Below is ShowCaption method of TTPhotoView

- (void)showCaption:(NSString*)caption {

UILabel* sampletext = [[UILabel alloc] initWithFrame:CGRectMake(60, 210, 150, 30)];
sampletext.opaque = NO;
sampletext.backgroundColor = [UIColor redColor];
sampletext.font = [UIFont fontWithName:@"Helvetica" size:14];

sampletext.text = @"Sample photo details";

[self addSubview:sampletext];

if (caption) {
    if (!_captionLabel) {
        _captionLabel = [[TTLabel alloc] init];
        _captionLabel.opaque = NO;
        _captionLabel.style = _captionStyle ? _captionStyle : TTSTYLE(photoCaption);
        //_captionLabel.alpha = _hidesCaption ? 0 : 1;
        [self addSubview:_captionLabel];
    }
}

_captionLabel.text = caption;
[self setNeedsLayout];

}

I am beginner in ios programming so any sample code is appreciated. Thanks a lot.


Solution

  • I could achieve this by adding subview to TTPhotoViewController subclass instead of TTPhotoView subclass.