iOS UI基础-3.0图片浏览器及plist使用

//
// UYViewController.m
// 3.0图片查看器
//
// Created by jiangys on 15/8/19.
// Copyright (c) 2015年 uxiaoyuan. All rights reserved.
// #import "UYViewController.h" @interface UYViewController ()
@property(nonatomic,strong) UILabel *noLabel;
@property(nonatomic,strong) UIImageView *iconImage;
@property(nonatomic,strong) UILabel *descLable;
@property(nonatomic,strong) UIButton *leftButton;
@property(nonatomic,strong) UIButton *rightButton; //显示当前的照片索引
@property(nonatomic,assign) int index; //图片信息的数组
@property(nonatomic,strong) NSArray *imageList; @end @implementation UYViewController -(NSArray *)imageList
{
if (_imageList==nil) {
NSString *path=[[NSBundle mainBundle] pathForResource:@"ImageList" ofType:@"plist"]; //在OC中,通常需要完整的路径
_imageList=[NSArray arrayWithContentsOfFile:path];
}
return _imageList;
} - (void)viewDidLoad
{
[super viewDidLoad]; //1.索引
_noLabel=[[UILabel alloc] initWithFrame:CGRectMake(, , self.view.frame.size.width, )];
_noLabel.text=@"1/5";
_noLabel.textAlignment=NSTextAlignmentCenter;
[self.view addSubview:_noLabel]; //2.图片
CGFloat imageW=;
CGFloat imageH=;
CGFloat imageX=(self.view.frame.size.width-imageW)*0.5;
CGFloat imageY=CGRectGetMidY(self.noLabel.frame)+; _iconImage=[[UIImageView alloc] initWithFrame:CGRectMake(imageX, imageY, imageW, imageH)];
_iconImage.image=[UIImage imageNamed:@"biaoqingdi"];
[self.view addSubview:_iconImage]; //3.描述
_descLable=[[UILabel alloc] initWithFrame:CGRectMake(, CGRectGetMaxY(self.iconImage.frame), self.view.frame.size.width, )];
_descLable.text=@"测试的拉";
_descLable.textAlignment=NSTextAlignmentCenter;
//需要Label具有“足够的高度”,不限制显示的行数
_descLable.numberOfLines=;
[self.view addSubview:_descLable]; //4.左边的按钮
_leftButton=[[UIButton alloc] initWithFrame:CGRectMake(, , , )];
CGFloat centerX=self.iconImage.frame.origin.x*0.5;
CGFloat centerY=self.iconImage.center.y;
_leftButton.center=CGPointMake(centerX, centerY);
_leftButton.tag=-; [_leftButton setBackgroundImage:[UIImage imageNamed:@"left_normal"] forState:UIControlStateNormal];
[_leftButton setBackgroundImage:[UIImage imageNamed:@"left_highlighted"] forState:UIControlStateHighlighted];
[_leftButton addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_leftButton]; //5.右边的按钮
_rightButton=[[UIButton alloc] initWithFrame:CGRectMake(, , , )];
_rightButton.center=CGPointMake(self.view.bounds.size.width-centerX, centerY); [_rightButton setBackgroundImage:[UIImage imageNamed:@"right_normal"] forState:UIControlStateNormal];
[_rightButton setBackgroundImage:[UIImage imageNamed:@"rigth_highlighted"] forState:UIControlStateHighlighted];
[self.view addSubview:_rightButton];
_rightButton.tag=;
[_rightButton addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside]; [self showPhotoInfo];
} -(void)clickButton:(UIButton *)button
{
//根据按钮调整当前显示图片的索引
self.index+=(int)button.tag;
[self showPhotoInfo];
} -(void)showPhotoInfo
{
self.noLabel.text=[NSString stringWithFormat:@"%d/%d",self.index+,];
self.iconImage.image=[UIImage imageNamed:self.imageList[self.index][@"name"]];
self.descLable.text=self.imageList[self.index][@"desc"]; self.rightButton.enabled=(self.index!=);
self.leftButton.enabled=(self.index!=);
} @end
plist文件的使用:
1.创建一个plist

2.填写为ImageList.plist

3.填入数据

4.完成

iOS UI基础-3.0图片浏览器及plist使用的更多相关文章
- iOS UI基础-4.0应用程序管理
功能与界面 功能分析: 以九宫格的形式展示应用信息 点击下载按钮后,做出相应的操作 步骤分析: 加载应用信息 根据应用的个数创建对应的view 监听下载按钮点击 整个应用界面: 程序实现 思路 UI布 ...
- iOS UI基础-17.0 UILable之NSMutableAttributedString
在iOS开发中,常常会有一段文字显示不同的颜色和字体,或者给某几个文字加删除线或下划线的需求.之前在网上找了一些资料,有的是重绘UILabel的textLayer,有的是用html5实现的,都比较麻烦 ...
- iOS UI基础-16.0 UIButton
回归自然,UIButton是我们使用最频烦的一个控件.下面,对该控件的一些常用方法进行一些总结. UIButton *payStateBtn = [UIButton buttonWithType:UI ...
- iOS UI基础-15.0 UIWebView
WebView介绍 知识点: 代码创建一个UIWebView OC调用html的js js页面调用OC 相关代码实现 代码创建一个UIWebView // 1.webView UIWebView *w ...
- iOS UI基础-10.0 QQ聊天布局之键盘及文本使用
要实现的效果: 这里只说用到的几个知识点 1.图片包含文字 在设置文字的Frame的时候,使用背景(按钮)的尺寸,文字使用了内边距 背景图片,使用拉伸 /** * 返回一张可以随意拉伸不变形的图片 ...
- iOS UI基础-9.0 UITableView基础
在iOS中,要实现表格数据展示,最常用的做法就是使用UITableView.UITableView继承自UIScrollView,因此支持垂直滚动,而且性能极佳. UITableView有两种样式: ...
- iOS UI基础-7.0 UIScrollView
概述 移动设备的屏幕大小是极其有限的,因此直接展示在用户眼前的内容也相当有限.当展示的内容较多,超出一个屏幕时,用户可通过滚动手势来查看屏幕以外的内容,普通的UIView不具备滚动功能,不能显示过多的 ...
- iOS UI基础-19.0 UICollectionView
直接上代码,说明请看注释吧 1.继承三个代理 UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateF ...
- iOS UI基础-13.0 数据存储
应用沙盒 每个iOS应用都有自己的应用沙盒(应用沙盒就是文件系统目录),与其他文件系统隔离.应用必须待在自己的沙盒里,其他应用不能访问该沙盒 应用沙盒的文件系统目录,如下图所示(假设应用的名称叫Lay ...
随机推荐
- sencha touch 简单的倒计时插件
效果如图: 代码: Ext.define('ux.label.Countdown', { alternateClassName: 'labelCountdown', extend: 'Ext.Comp ...
- openstack-networking-neutron(二)---tun/tap
本博客已经添加"打赏"功能,"打赏"位置位于右边栏红色框中,感谢您赞助的咖啡. 简介 虚拟网卡Tun/tap驱动是一个开源项目,支持很多的类UNIX平台,Ope ...
- Python 安装出错:Setup script exited with error: command 'gcc' failed with exit status 1
退出当前环境: logout (再重新登录进去) yum install python-devel -yyum install libevent-devel -y 把环境更新下yum instal ...
- SSH使用秘钥和别名登陆服务器
手工配置免密码及别名登陆 第一步:生成秘钥 $ ssh-keygen -t rsa 第二步:上传公钥到目标服务器 $ ssh-copy-id -i ~/.ssh/id_rsa.pub <romt ...
- 使用iLO远程管理HP系列服务器
iLO是Integrated Ligths-out的简称,是HP服务器上集成的远程管理端口,它是一组芯片内部集成vxworks嵌入式操作系统,通过一个标准RJ45接口连接到工作环境的交换机.只要将服务 ...
- 【CF840C】On the Bench DP
[CF840C]On the Bench 题意:给你一个长度为n的数组{ai},定义一个1到n的排列是合法的,当且仅当对于$1\le i <n$,$a_i\times a_{i+1}$不是完全平 ...
- mysql概要(六)连接(内连接,左,右外连接
内连接 [join on / from 表1,表二 ]效果一样 区别是:可以理解为首先取得笛卡儿积后,再匹配/还是根据条件获得笛卡尔积 内连接:取俩表的交叉匹配数据:(mysql 内连接 左连接 右连 ...
- Unity3D笔记 模型和角色动画的输出设置
- linux启动程序和关闭程序脚本
关闭脚本: #!/bin/bash source /etc/profile log() { echo `date +[%Y-%m-%d" "%H:%M:%S]` $1 } log ...
- mysql操作常用技巧
删除一张表的数据,条件在另一张表 delete a from A a,B b where a.tel=b.tel and a.code=b.code and a.day='201808';