0

我有一个基于故事板的应用程序,我想使用 MWPhotoBrowser。我使用 cocoaPods 将 MWPhotoBrowser 添加到我的项目中。在我的故事板中,我有一个名为 PhotoBrowserViewController 的视图控制器,我通过从另一个视图控制器的按钮推送来访问它。在我的 PhotoBrowerViewController 中,我只能看到我设置的标题而不是我添加的照片?谁能帮我?

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
4

1 回答 1

0

首先,检查您是否已使此类符合MWPhotoBrowserDelegate

(id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index其次,您需要从方法中返回 MWPhoto 对象

我认为这就是问题所在

于 2015-02-13T06:36:21.207 回答