when I try to add 'MWPhotoBrowser' to my photo browser project, and I want make an Photo Grid view, but when I run it ,it was crashed, it motioned Thread 1 breakpoint 5.1, I have pasted my code below
code of h.file:
#import <Foundation/Foundation.h>
#import "MWPhotoBrowser.h"
#import <AssetsLibrary/AssetsLibrary.h>
@interface DEMOSevenViewController : UIViewController <MWPhotoBrowserDelegate>
{
NSArray *_photos;
}
@end
code of m.file:
#import "DEMOSevenViewController.h"
#import "SDImageCache.h"
@interface DEMOSevenViewController ()
@end
@implementation DEMOSevenViewController
#pragma mark - MWPhotoBrowserDelegate-
-(NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser
{
return _photos.count;
}
- (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index
{
if (index < _photos.count)
return [_photos objectAtIndex:index]; return nil;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableArray *photos = [[NSMutableArray alloc] init];
for (int i = 0; i < 12; i++)
{
MWPhoto* photo = [MWPhoto photoWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"photo5" ofType:@"jpg"]]];
photo.caption = @"Fireworks";
[photos addObject:photo];
}
_photos = photos;
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.displayActionButton = YES;
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:browser];
nc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:nc animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
- (void)viewDidLoad{
[super viewDidLoad];
[self performSelector:@selector(getAllPhoto) withObject:nil afterDelay:0.5];
}
-(void)getAllPhoto{
NSMutableArray *photos = [[NSMutableArray alloc] init];
for (int i = 0; i < 12; i++)
{
MWPhoto* photo = [MWPhoto photoWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"photo5" ofType:@"jpg"]]];
photo.caption = @"Fireworks";
[photos addObject:photo];
}
_photos = photos;
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.displayActionButton = YES;
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:browser];
nc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:nc animated:YES];
}