MWPhotoBrowser icon indicating copy to clipboard operation
MWPhotoBrowser copied to clipboard

Caption subclass doesn't populate MWPhoto

Open ghost opened this issue 13 years ago • 3 comments

I have a very basic subclass of MWCaption and have everything working except the MWPhoto object is not initialized within my subclass for some reason. I have confirmed it's properly initialized in MWCaptionView and in my delegate.

My subclass has the following:

//Private variables id _photo; UILabel *_label; UILabel *_button;

//Methods: - (void)setupCaption -(CGSize)sizeThatFits:(CGSize)size

My delegate in my other class is the following:

- (MWCaptionView *)photoBrowser:(MWPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index
{
    MWPhoto *photo = [_photos objectAtIndex:index];
    NSLog(@"The caption: %@", photo.caption);  //Working as expected
    PlayerCaption *captionView = [[PlayerCaption alloc] initWithPhoto:photo];
    return captionView;
}

Both the delegate and the MWCaptionView have a handle on the MWPhoto object, but for some reason it's null in my class.

ghost avatar Nov 04 '13 16:11 ghost

I just copied initWithPhoto into my subclass. Works, but doesn't seem like the correct implementation

ghost avatar Nov 04 '13 16:11 ghost

The internal variable in the caption view that holds the photo is _photo not photo. This is probably what's causing your problem.

mwaterfall avatar Nov 08 '13 10:11 mwaterfall

i've the same problem. If i subclass MWCaptionView, in the implementation there is no way to access _photo (couse it's set private in MWCaptionView). What am i doing wrong?

EDIT - here is my solution:

@interface MWCaptionViewCustom : MWCaptionView { MWPhotoCustom *_photo; }

in implementation:

-(id)initWithPhoto:(MWPhotoCustom *)photo { _photo = photo; return [super initWithPhoto:photo]; }

then the _photo contains all of my custom values. is it good?

monteduro avatar May 13 '14 18:05 monteduro