MWPhotoBrowser 属性详解 和代理解释

2023-05-16

原文:http://blog.csdn.net/hsf_study/article/details/51783989


--------0.MWPhoto简单属性解释----------------  


MWPhoto *photo = [MWPhoto photoWithURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3629/3339128908_7aecabc34b.jpg"]];
photo.caption = @"在将photo添加到数组中时,可以在这里设置标题名字";  


   photo = [MWPhotophotoWithURL:[NSURLfileURLWithPath:[[NSBundlemainBundle] pathForResource:@”photo2”ofType:@”jpg”]]];

            photo.caption =@”The London Eye is a giant Ferris wheel situated on the banks of the River Thames, in London, England.”;

[photos addObject:photo];

效果图
==============================1.属性详解==========================

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

  //分享按钮,默认是

  browser.displayActionButton =NO;


  //底部是否分页切换导航,默认否

  browser.displayNavArrows =NO;


  是否显示选择按钮在图片上,默认否

  browser.displaySelectionButtons =YES;


  //控制条件控件是否显示,默认否

  browser.alwaysShowControls =NO;


  //自动适用大小,默认是

  browser.zoomPhotosToFill =YES;



  //是否允许用网格查看所有图片,默认是

  browser.enableGrid =NO;


  是否第一张,默认否

  browser.startOnGrid =YES;


  //是否开始对缩略图网格代替第一张照片

  browser.enableSwipeToDismiss =NO;


  //是否自动播放视频

  browser.autoPlayOnAppear =NO;


  //播放页码

  [browser setCurrentPhotoIndex:0];


  //自定义选择按钮的样式

  //大图时显示选择按钮,(图片大小要和ImageSelectedOn图大小一致)

  // browser.customImageSelectedIconName = @”选中“;


  //选择多图的时候,图片大小要和ImageSelectedSmallOn图大小一致)

  //  browser.customImageSelectedSmallIconName = @”选中“;


  [self.navigationControllerpushViewController:browseranimated:YES];


==============================2.代理方法解释==========================

/*****************************必须实现的代理方法********************************/

//有多少个图片要显示

- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {

  returnself.photoesArray.count;

}


//在具体的index中,显示网络加载或者本地的某一个图片

- (id<MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser

               photoAtIndex:(NSUInteger)index {

  if (index <self.photoesArray.count) {

    return [self.photoesArrayobjectAtIndex:index];

  }

  returnnil;

}

图片效果图:


/*****************************可选实现的代理方法********************************/

//自定义标题

- (NSString *)photoBrowser:(MWPhotoBrowser *)photoBrowser

      titleForPhotoAtIndex:(NSUInteger)index {

  return [NSStringstringWithFormat:@”%lu/%lu”, (unsignedlong)index,

                                    (unsignedlong)self.photoesArray.count];

}

图片效果图:



//加载多张网络缩略图(enableGrid YES)时,才可以实现该委托方法

- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser thumbPhotoAtIndex:(NSUInteger)index{

    if (index <self.photoesArray.count) {

        return [self.photoesArrayobjectAtIndex:index];

    }

    returnnil;

}

效果图显示 1 和 2:




//自定义底部视图,继承MWCaptionView这个类,在子类中重写-setupCaption -sizeThatFits:,或者加视图。

- (MWCaptionView *)photoBrowser:(MWPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index{

    MWPhoto *photo = [self.photoesArrayobjectAtIndex:index];

    MWCaptionView *captionView = [[MWCaptionViewalloc]initWithPhoto:photo];

//    captionView.

    return captionView;


}

效果视图:

//displayActionButton(分享按钮)设置为YES时,这个方法才会触发。之前的分享动作就不会出现。

- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser actionButtonPressedForPhotoAtIndex:(NSUInteger)index{

    NSLog(@”content %lu”,(unsignedlong)index);

}

效果图



//当前将要显示第几张

- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser didDisplayPhotoAtIndex:(NSUInteger)index{

    NSLog(@”content %lu”,(unsignedlong)index);

}

效果图:



//设置将要显示的视图,是否被选或者没有被选,把它放到一个数组中。

- (BOOL)photoBrowser:(MWPhotoBrowser *)photoBrowser isPhotoSelectedAtIndex:(NSUInteger)index {

    return [[_selectionsobjectAtIndex:index] boolValue];

}

//当前显示图片,选择按钮是否被选,或者没有被选,会触发这个方法

- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index selectedChanged:(BOOL)selected {

    [_selectionsreplaceObjectAtIndex:index withObject:[NSNumbernumberWithBool:selected]];

    NSLog(@”Photo at index %lu selected %@”, (unsignedlong)index, selected ? @”YES” :@”NO”);

}




如果是modal出来的,必须手动dismiss

/*

 当要modal出来的时候,需要使用包装上一个UINavigationController,它可以来管理多张图问题。

 UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:browser];

 nc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

 [self presentViewController:nc animated:YES completion:nil];


 */

- (void)photoBrowserDidFinishModalPresentation:(MWPhotoBrowser *)photoBrowser{

    [self dismissViewControllerAnimated:YES completion:nil];

}



本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

MWPhotoBrowser 属性详解 和代理解释 的相关文章

  • Aspose.Words for Java 体验

    公司中要做一些导出word的工作 xff0c 经别人推荐 xff0c 使用了Aspose Words for Java xff0c 感觉很好用 xff0c 美中不足的地方就是 xff0c 它是收费软件 原理吗 xff1f 比较常规 xff0
  • 汽车制造行业OEM Tier1 Tier2指代什么?

    OEM OEM是Original Equipment Manufacturer的缩写 xff0c 通常指设备厂商 主机厂 整车厂 例如 xff1a 宝马 奔驰 奥迪 大众 丰田 国内汽车主机厂排名前十分别是上汽集团 东风汽车 北京汽车 长安
  • Android应用系统签名方法

    1 应用配置sharedUserId 在AndroidManifest xml文件根节点中加入属性 xff1a android sharedUserId 61 34 android uid system 34 2 找到系统签名文件 plat
  • Android 读取CPU/GPU运行参数(MTK平台)

    一 使用场景 Android运行一段世时间后 xff0c 系统出现卡顿 二 分析 amp 定位问题 系统卡顿 xff0c 同时又发现芯片温度很高 xff0c 怀疑是温度过高导致CPU降频 xff0c 因此我们要将一段时间内CPU的运行信息打
  • Android签名 (二) 制作签名文件

    你可能想知道 通过这篇博客可以解决哪些问题以及学到什么 xff1a 1 公司开发一个新的app xff0c 如何创建一个应用签名 xff1f 2 为了安全性 xff0c Android系统不想使用Google给的原生签名 xff0c 如何定
  • Android签名 (一) 查看签名信息

    你可能想知道 通过这篇博客可以解决哪些问题以及学到什么 xff1a 1 如果我们有一个应用 xff0c 如何查看应用的签名信息 xff1f 2 如果我们有签名原始文件 xff0c 如何查看签名文件中的签名信息 xff1f 这篇博客介绍了如何
  • L8 U3 职业生涯

    Module 1 谈论你最近的工作 1 描述工作 描述工作的形容词 让我们来看一下可以用来描述工作 xff0c 项目和客户的形容词 用enjoyable 和 engaging来描述你觉得有意思的工作或者项目 For me sales is
  • L8 U4 商务旅行

    Module 1 计划商务旅行 1 处理信息 You mean with Lindstrom 你是说和林特罗姆 xff1f Yes with Lindstrom 是的 xff0c 和林特罗姆 Exactly 完全正确 You mean yo
  • L8 U5 产品和创新

    Module 1 产品特点 1 产品特点 询问产品特性 在询问商店中的产品时 xff0c 您可能首先想询问其质量水平 top of the range 高档的middle of the range 中档的good value for mon
  • Android打包jar的两种方法

    方法一 xff1a 使用Android Studio打包 方法二 xff1a 使用Android Build System打包 一 Android Studio打包 1 新建Android Library xff0c 取名为opensdk
  • LCS 下载插件

    难度简单2收藏分享切换为英文接收动态反馈 小扣打算给自己的 VS code 安装使用插件 xff0c 初始状态下带宽每分钟可以完成 1 个插件的下载 假定每分钟选择以下两种策略之一 使用当前带宽下载插件将带宽加倍 xff08 下载插件数量随
  • 调用webservice异常总结

    发布和调用Webservice很简单 xff0c 但小问题依然不断 xff0c 特总结如下 xff1a 一 Java调用 net的webService产生 服务器未能识别 HTTP 标头 SOAPAction 的值 错误 解决方案 xff1
  • 去除Evaluation Warning : The document was created with Spire.PDF for Java.

    去除Evaluation Warning The document was created with Spire PDF for Java 最近项目中有一个需求需要把PDF文件添加页码 xff0c 最终在网上找到了用Spire去添加的方法
  • 第二章 简单网页的爬取与Xpath、Json使用 2021-09-09

    爬虫系列总目录 本章节介绍爬虫中使用的基础库用于选择 xff0c 过滤页面信息 包括requests xff0c bs4 xff0c xpath xff0c 正则表达式re xff0c json 等内容 xff0c 能够实现对简单页面的获取
  • 解决crontab定时任务多次执行

    今天使用linux crontab定时任务时 xff0c 可能由于配置不妥 xff0c 任务多执行一次 xff0c 如下是我程序的日志记录 xff08 执行了两次 xff0c 我设置的是每分钟执行1次 xff09 解决如下 重启cronta
  • ruoyi对接CAS统一身份认证

    暂定逻辑如下 xff1a 搭建CAS服务器端 xff1a 项目地址 xff1a https gitee com weigang wu cas server webapp git 项目里有二开的说明文档 xff0c 如 xff1a 按照自定义
  • Linux 系统启动过程

    简介 Linux 系统启动过程大致分为5个阶段 xff1a 1 内核的引导 2 运行 init 3 系统初始化 4 建立终端 5 用户登录系统 内核引导 计算机通电后 xff0c 首先会进行 BIOS 开机自检 xff0c 然后根据BIOS
  • Ubuntu 修改$PS1 自定义命令提示符

    文章更新于 xff1a 2020 03 25 文章目录 一 自定义命令提示符1 可修改的是那部分 xff1f 2 修改 PS1 变量3 PS1 变量格式4 如何修改背景颜色5 修改字体 二 Enjoy xff01 一 自定义命令提示符 1
  • C#byte类型

    byte类型的范围是0 255 转换为二进制是00000000 11111111 C 中对byte类型的处理还是很特殊的 下面用几行简单的代码来说明问题 byte x 61 1 byte y 61 2 byte z 61 x 43 y er
  • JVM内存分配机制详解

    目录 1 对象创建流程 TODO 1 1 jvm分配内存 1 2 设置对象头 1 2 1 对象头实例 1 2 2 指针压缩 2 JVM对象内存分配 2 1 逃逸分析和标量替换 2 1 1 逃逸分析和标量替换实战 2 2 eden区分配内存过

随机推荐