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 ...
随机推荐
- 【ORACLE 】 ORA-00031 标记要删去的会话(解决)
在使用Oracle的过程中,会有使用了锁(for update)但又忘记释放锁的情况.这是就需要用到KILL语句了.(如果不知道KILL语句怎么用,可参考: http://www.cnblogs.co ...
- python tkinter Listbox用法
python tkinter组件的Listbox的用法,见下面代码的演示: from tkinter import * root=Tk() v=StringVar() #Listbox与变量绑定' l ...
- C# mongohelper的初始化及账户密码设置
MongoClientSettings mongoSettings = new MongoClientSettings(); TimeSpan t = ); mongoSettings.Connect ...
- linux下php redis扩展安装
sudo tar vxzf redis-2.2.7.tgz cd redis-2.2.7 执行sudo /data/service/php54/bin/phpize 在目录下生成配置文件 sudo . ...
- tornado web开发
tornado是python的web框架,这里简单记录下利用tornado怎么实现文件的上传,其中web.py上传功能类似. 直接用代码说明: 代码来自:http://my.oschina.net ...
- C# 日志系统 log4net 配置及使用
1.引用Dll 版本是:1.2.10.0,下载Dll 2.Web.config文件配置 <?xml version="1.0" encoding="utf-8&qu ...
- centos7搭建docker私有仓库
1.环境: [root@docker02 anchors]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@do ...
- Android开发小技巧之根据position判断ListView是否在显示
使用ListView的时候,会有判断指定项是否正在显示的需求,其实很简单,代码如下: private boolean isShowing(int position) { int showViewCou ...
- thinkCMF----如何写标签
ThinkCMF写标签的地方:
- 前端基础进阶之Promise
前言 Promise的重要性我认为我没有必要多讲,概括起来说就是必须得掌握,而且还要掌握透彻.这篇文章的开头,主要跟大家分析一下,为什么会有Promise出现. 在实际的使用当中,有非常多的应用场景我 ...