Ios 将照片添加到照片浏览器

Ios 将照片添加到照片浏览器,ios,uicollectionview,mwphotobrowser,Ios,Uicollectionview,Mwphotobrowser,我有我的第一个视图控制器imageResults,并在其中使用下面的代码调用MWPhotoBrowser。我看到它使用self.photos中的数据显示了一个新的视图控制器。我尝试了几种添加更多数据的方法,但都没有成功。我希望能够在新视图中加载更多数据并将其添加到photobrowser,添加更多数据部分已经没有了,现在如何设置当前浏览器以加载新阵列而不丢失当前位置 -(void)mvTouched:(NSIndexPath *)indexPath { NSLog(@"Arr:%

我有我的第一个视图控制器imageResults,并在其中使用下面的代码调用MWPhotoBrowser。我看到它使用self.photos中的数据显示了一个新的视图控制器。我尝试了几种添加更多数据的方法,但都没有成功。我希望能够在新视图中加载更多数据并将其添加到photobrowser,添加更多数据部分已经没有了,现在如何设置当前浏览器以加载新阵列而不丢失当前位置

    -(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!!!");
}
-(void)mvxpath:(nsindepath*)indepath{
NSLog(@“Arr:%lu Url:%lu”,[title可变计数],[mediaUrlDict计数];
NSMutableArray*tmpPhotos=[NSMutableArray];
for(标题可变表中的NSString*标题字符串){
NSString*url=[mediaUrlDict objectForKey:titleString];
MWPhoto*currentPhoto=[MWPhoto photoWithURL:[NSURL URLWithString:url]];
currentPhoto.caption=[NSString stringWithFormat:@“%@”,标题字符串];
[tmpPhotos addObject:currentPhoto];
//[tmpPhotos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:url]];
}
self.photos=[NSArray arrayWithArray:tmpPhotos];
MWPhotoBrowser*浏览器=[[MWPhotoBrowser alloc]initWithDelegate:self];
//设置选项
browser.displayActionButton=YES;//显示允许共享、复制等的操作按钮(默认为YES)
browser.displayNavArrows=YES;//是否在工具栏上显示左右导航箭头(默认为否)
browser.displaySelectionButtons=NO;//是否在每个图像上显示选择按钮(默认为NO)
browser.zoomPhotosToFill=YES;//几乎填满屏幕的图像最初将缩放为填充(默认为YES)
browser.alwaysShowControls=YES;//允许控制条和控件是否始终可见,或者它们是否淡出以显示完整的照片(默认为否)
browser.enableGrid=YES;//是否允许查看网格上的所有照片缩略图(默认为YES)
browser.startOnGrid=NO;//是否从缩略图网格而不是第一张照片开始(默认为NO)
browser.edgesForExtendedLayout=是;
browser.extendedlayoutincludesopaquebar=是;
//(可选)在显示前设置当前可见照片
//[浏览器设置CurrentPhotoIndex:1];
[浏览器setCurrentPhotoIndex:indexath.row];
self.navigationController.navigationBar.hidden=NO;
//出席
[self.navigationController pushViewController:浏览器动画:是];
//操纵
[浏览器显示下一张照片动画:是];
[浏览器showPreviousPhotoAnimated:是];
//[浏览器设置CurrentPhotoIndex:1];
[浏览器setCurrentPhotoIndex:indexath.row];
[浏览器重新加载数据];
}
-(无效)加载更多{
[自添加数据到阵列];
//[自我评价:无];
[self.collectionView-reloadData];
}
-(NSInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser*)photoBrowser{
返回_photos.count;
}
-(id)photoBrowser:(MWPhotoBrowser*)photoBrowser photoAtIndex:(NSUInteger)索引{
如果(索引<_照片计数)
返回[_photosobjectatindex:index];
返回零;
}
-(无效)照片浏览器:(MWPhotoBrowser*)照片浏览器操作按钮按下照片索引:(NSInteger)索引{
//做你的事!
NSLog(@“ACTION!!!”);
}

调用[self.collectionView reloadData]只会重新加载当前视图的集合,而不是MWPhotoBrowser的集合。您需要调用browsers reloadData函数,才能像这样工作:

[browser reloadData]
请注意,当前浏览器集合视图在调用此方法后未显示新照片存在问题。我通过将以下代码添加到MWPhotoBrowser.m文件中的reloadData方法中,设法解决了这个问题:

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

调用[self.collectionView reloadData]只会重新加载当前视图的集合,而不是MWPhotoBrowser的集合。您需要调用browsers reloadData函数,才能像这样工作:

[browser reloadData]
请注意,当前浏览器集合视图在调用此方法后未显示新照片存在问题。我通过将以下代码添加到MWPhotoBrowser.m文件中的reloadData方法中,设法解决了这个问题:

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

我在处理同样的问题。然而,最重要的问题是将在浏览器中加载更多数据的方法放在何处。我想要它,这样当我在浏览器中访问(在你的情况下)u photos.count时,它将加载其他图像。我正在处理相同的问题。然而,最重要的问题是将在浏览器中加载更多数据的方法放在何处。我需要它,这样当我在浏览器中访问(在您的情况下)u photos.count时,它将加载其他图像。