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!!!");
}
我有點處理同樣的問題。然而,除此之外,還有一個問題是在瀏覽器中加載更多數據的方法。我需要它,以便當我到達(在你的情況下)_photos.count在瀏覽器中它會加載其他圖像。 – user2197126 2015-01-14 20:14:54