2014-09-23 3 views
0

내 첫 번째보기 컨트롤러가 imageResults이고 아래 코드로 MWPhotoBrowser가 호출됩니다. self.photos에서 가져온 데이터를 사용하여 새로운보기 컨트롤러를 표시합니다. 더 많은 데이터를 추가하기위한 몇 가지 옵션을 시도했지만 성공하지 못했습니다. 새보기에서 더 많은 데이터를로드하고 포토 브라우저에 추가 할 수 있기를 원한다면 데이터 부분을 더 추가하는 것이 이미 필요하지 않습니다. 현재 위치를 잃지 않고 새 배열을로드하도록 현재 브라우저를 설정하는 방법은 무엇입니까?MWPhotoBrowser에 사진 추가

-(void)mvTouched:(NSIndexPath *)indexPath { 
    NSLog(@"Arr:%lu Url:%lu", [titlesMutable count], [mediaUrlDict count]); 

    NSMutableArray *tmpPhotos = [NSMutableArray array]; 
    for(NSString *titleString in titlesMutable) { 
     NSString *url = [mediaUrlDict objectForKey:titleString]; 
     MWPhoto *currentPhoto = [MWPhoto photoWithURL:[NSURL URLWithString:url]]; 
     currentPhoto.caption=[NSString stringWithFormat:@"%@", titleString]; 
     [tmpPhotos addObject:currentPhoto]; 
     //[tmpPhotos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:url]]]; 

    } 
    self.photos = [NSArray arrayWithArray:tmpPhotos]; 


    MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self]; 

    // Set options 
    browser.displayActionButton = YES; // Show action button to allow sharing, copying, etc (defaults to YES) 
    browser.displayNavArrows = YES; // Whether to display left and right nav arrows on toolbar (defaults to NO) 
    browser.displaySelectionButtons = NO; // Whether selection buttons are shown on each image (defaults to NO) 
    browser.zoomPhotosToFill = YES; // Images that almost fill the screen will be initially zoomed to fill (defaults to YES) 
    browser.alwaysShowControls = YES; // Allows to control whether the bars and controls are always visible or whether they fade away to show the photo full (defaults to NO) 
    browser.enableGrid = YES; // Whether to allow the viewing of all the photo thumbnails on a grid (defaults to YES) 
    browser.startOnGrid = NO; // Whether to start on the grid of thumbnails instead of the first photo (defaults to NO) 
    browser.edgesForExtendedLayout = YES; 
    browser.extendedLayoutIncludesOpaqueBars = YES; 

    // Optionally set the current visible photo before displaying 
    //[browser setCurrentPhotoIndex:1]; 
    [browser setCurrentPhotoIndex:indexPath.row]; 

    self.navigationController.navigationBar.hidden=NO; 
    // Present 
    [self.navigationController pushViewController:browser animated:YES]; 

    // Manipulate 
    [browser showNextPhotoAnimated:YES]; 
    [browser showPreviousPhotoAnimated:YES]; 
    //[browser setCurrentPhotoIndex:1]; 
    [browser setCurrentPhotoIndex:indexPath.row]; 


    [browser reloadData]; 
} 
-(void)loadMore { 
    [self addDataToArray]; 
    //[self mvTouched:nil]; 



    [self.collectionView reloadData]; 

} 
- (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; 
} 
- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser actionButtonPressedForPhotoAtIndex:(NSUInteger)index { 
    // Do your thing! 

    NSLog(@"ACTION!!!"); 
} 
+0

나는 같은 문제를 다루고 있습니다. 그러나 그 문제의 꼭대기에는 브라우저에 더 많은 데이터를로드하는 메소드를 어디에 두어야하는지에 대한 문제가 있습니다. 나는 그것이 (당신의 경우) 브라우저에서 _photos.count에 도달 할 때 다른 이미지를로드하기를 원한다. – user2197126

답변

5

[self.collectionView reloadData]를 호출하면 MWPhotoBrowser 대신 현재보기의 컬렉션 만 다시로드됩니다. 당신은 너무처럼 작동이의 브라우저에게 reloadData 함수를 호출해야합니다 현재 브라우저 수집보기이 메서드를 호출 한 후 새로운 사진을 표시하지에 문제가 있음을

[browser reloadData] 

참고. MWPhotoBrowser.m 파일에있는 reloadData 메서드에이 코드를 추가하여이 문제를 해결할 수있었습니다.

if (_gridController) { 
    [_gridController.collectionView reloadData]; 
}