1

'MWPhotoBrowser' をフォト ブラウザー プロジェクトに追加しようとして、フォト グリッド ビューを作成したいのですが、実行するとクラッシュし、スレッド 1 ブレークポイント 5.1 を動かしました。以下にコードを貼り付けました。

h.file のコード:

#import <Foundation/Foundation.h>

#import "MWPhotoBrowser.h"
#import <AssetsLibrary/AssetsLibrary.h>


@interface DEMOSevenViewController : UIViewController <MWPhotoBrowserDelegate>
{
NSArray *_photos;
}
@end

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
4

1 に答える 1

0
 - (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];
}
于 2014-03-05T10:36:29.633 に答える