How to use MWPhotoBrowser in storyboard based app?

437 views Asked by At

I have a storyboard based app and I want to use the MWPhotoBrowser. I added MWPhotoBrowser to my project using cocoaPods. In my storyboard, I have view controller called PhotoBrowserViewController that I accessed by a push from another view controller's button. In my PhotoBrowerViewController, I'm only able to see the title that I set and not the photo that I added? Can anyone help me?

PhotoBrowserViewController.h

#import <UIKit/UIKit.h>
#import "MWPhotoBrowser.h"
@interface PhotoBrowserViewController : UIViewController<MWPhotoBrowserDelegate>

@property (nonatomic, strong) NSMutableArray *photos;
@end

PhotoBrowserViewController.m

#import "PhotoBrowserViewController.h"

@interface PhotoBrowserViewController ()
@end

@implementation PhotoBrowserViewController

- (void)awakeFromNib
{
    self.title = @"MWPhotoBrowser";
    MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
    browser.displayActionButton = YES;
    [self.photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://www.ournorthstar.com/wp-content/uploads/2013/10/test1.jpg"]]];

}


- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
    return _photos.count;
}

- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
    if (index < _photos.count)
        return [_photos objectAtIndex:index];
    return nil;
}

@end
1

There are 1 answers

0
Ehmad Zubair On

Firstly, check if you have conformed this class to MWPhotoBrowserDelegate

Secondly, you need to return MWPhoto object from the (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index method

I think that's the problem