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