Ios MWPhotoBrowser不在导航标题中显示单个图像的显示图像名称

Ios MWPhotoBrowser不在导航标题中显示单个图像的显示图像名称,ios,iphone,Ios,Iphone,我正在使用MWPhotoBrowser在导航中显示图像。对于多个图像,它工作正常。但当显示一个图像(图像数为1)时,它不会将图像名称显示为导航栏的标题。我该如何解决这个问题?以下是委托方法的代码: - (void) photoBrowser:(MWPhotoBrowser *)photoBrowser didDisplayPhotoAtIndex:(NSUInteger)index { NSLog(@"Photo displayed"); if (index < [self.imagesG

我正在使用MWPhotoBrowser在导航中显示图像。对于多个图像,它工作正常。但当显示一个图像(图像数为1)时,它不会将图像名称显示为导航栏的标题。我该如何解决这个问题?以下是委托方法的代码:

- (void) photoBrowser:(MWPhotoBrowser *)photoBrowser didDisplayPhotoAtIndex:(NSUInteger)index {
NSLog(@"Photo displayed");
if (index < [self.imagesGallery count]) {
    NSString *imageName = [self.imagesGallery objectAtIndex:index];

    photoBrowser._titleText = [imageName stringByDeletingPathExtension];
    NSLog(@"Title: %@", photoBrowser._titleText);
    NSString *element = [[[imageName stringByDeletingPathExtension] componentsSeparatedByString:@"-"] objectAtIndex:1];
    int index_ = [deficiencesShort indexOfObject:element];
    photoBrowser._actionButton.title = [NSString stringWithFormat:@"Go To %@ Deficiency", [deficiences objectAtIndex:index_]];
}
-(void)photoBrowser:(MWPhotoBrowser*)photoBrowser显示PhotoAtIndex:(nsInteger)索引{
NSLog(@“照片显示”);
如果(索引<[self.imagesGallery count]){
NSString*imageName=[self.imagesGallery objectAtIndex:index];
photoBrowser._titleText=[imageName stringByDeletingPathExtension];
NSLog(@“标题:%@”,照片浏览器。\u titleText);
NSString*元素=[[[imageName stringByDeletingPathExtension]组件由字符串分隔:@“-“]objectAtIndex:1];
int index=[缺陷短索引对象:元素];
photoBrowser._actionButton.title=[NSString stringWithFormat:@“转到%@缺陷”,“缺陷对象索引:索引];
}
}


对于单个图像,NSLog(@“Title:%@”,photoBrowser.\u titleText)将图像名称显示为输出,但未设置为导航栏标题

如果您使用MWPhotoBrowser库进行了一些更改,请显示代码

设置浏览器导航的标题:

  • 在MWPhoto中添加name属性
  • handleMWPhotoLoadingDidEndNotification中的修饰符updateNavigation方法在updateNavigation中传递标题(MWPhotoBrowser.m中的两个函数)

  • MWPhotoBrowser.m
    文件中的
    updateNavigation
    方法中放入以下条件

    删除
    self.title=nil
    并将此条件添加到else部分

        if ([_delegate respondsToSelector:@selector(photoBrowser:titleForPhotoAtIndex:)]) {
            self.title = [_delegate photoBrowser:self titleForPhotoAtIndex:_currentPageIndex];
        }
        else {
            self.title = nil;
        }
    
    确保您需要实现
    photoBrowser:titleForPhotoAtIndex
    delegate