Caption subclass doesn't populate MWPhoto
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
//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.
I just copied initWithPhoto into my subclass. Works, but doesn't seem like the correct implementation
The internal variable in the caption view that holds the photo is _photo not photo. This is probably what's causing your problem.
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?