2014-03-05 2 views
1

을 수행 할 때 사진 격자보기를 만들지 만 실행하면 충돌이 발생하여 스레드 1을 움직입니다. m.file의내 프로젝트에서 MWPhotoBrowser를 사용할 때 스레드 1 중단 점 5.1을 사용합니다. 내 사진 브라우저 프로젝트에 'MWPhotoBrowser'를 추가하려고 할 때

#import <Foundation/Foundation.h> 

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


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

코드 :

#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 
+0

일을보기 바랍니다 5.1 브레이크 포인트, 나는 h.file의

코드 아래에 내 코드를 붙여 넣은 e 충돌 로그 –

+0

ViewDidLoad에 MWPhotoBrowser를 표시하려고하면 문제가 발생합니다. 이 코드를 viewDidAppear 메서드에 추가하십시오. –

+0

안녕하세요 형제 님, 조언을 주셔서 감사합니다. ViewDidAppear 메서드에이 코드를 추가했지만 실행하면 격자보기가 표시되지 않습니다. – user3376284

답변

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]; 
} 
+0

와우 .it 작품, 정말 고마워요!하지만 실행할 때 그리드보기를 보여주고 싶습니다. 그리고 그 중 하나를 탭하면 탭 하나가 크게 확대됩니다. 어떻게해야합니까? 나는 git에 WMPhotoBrowser를 보여줍니다. git에서 m.file을 확인하십시오. [https://github.com/mwaterfall/MWPhotoBrowser/blob/master/Demo/PhotoBrowserDemo/Menu.m] – user3376284