UI基础-04图片浏览器
来源:互联网 发布:阿里云医疗 编辑:程序博客网 时间:2024/06/11 03:30
<pre name="code" class="objc">//// ViewController.m// UI基础-04图片浏览器//// Created by NorthCity on 15/9/7.// Copyright (c) 2015年 Tcg. All rights reserved.//#import "ViewController.h"@interface ViewController ()@property (weak, nonatomic) IBOutlet UILabel *indexLabel;@property (weak, nonatomic) IBOutlet UIImageView *imageView;@property (weak, nonatomic) IBOutlet UIButton *leftButton;@property (weak, nonatomic) IBOutlet UIButton *rightButton;@property (weak, nonatomic) IBOutlet UILabel *infoLabel;//数组保存图片信息和图片名字的字典@property(strong,nonatomic) NSArray *imageData;//index用来指示第几张图片@property(nonatomic,assign) int index;@end@implementation ViewController- (void)viewDidLoad { self.index = 0; [self reloadView]; }//这里重写数组的get方法,好处随用随取-(NSArray*)imageData{ if (_imageData == nil) { // 注意这里用可变字典啊 NSMutableDictionary *imge0 =[NSMutableDictionary dictionary]; imge0[@"icon"] = @"biaoqingdi"; imge0[@"info"] = @"在他面前,其他神马表情都弱爆了!"; NSMutableDictionary *imge1 =[NSMutableDictionary dictionary]; imge1[@"icon"] = @"wangba"; imge1[@"info"] = @"哥们为什么选八号呢"; NSMutableDictionary *imge2 =[NSMutableDictionary dictionary]; imge2[@"icon"] = @"bingli"; imge2[@"info"] = @"这也忒狠了"; NSMutableDictionary *imge3 =[NSMutableDictionary dictionary]; imge3[@"icon"] = @"chiniupa"; imge3[@"info"] = @"这小姑娘吃个牛排比杀牛还费劲啊"; NSMutableDictionary *imge4 =[NSMutableDictionary dictionary]; imge4[@"icon"] = @"danteng"; imge4[@"info"] = @"亲,你能改下你的网名么?哈哈"; _imageData = @[imge0,imge1,imge2,imge3,imge4]; } return _imageData;}-(void)reloadView{ self.indexLabel.text =[ NSString stringWithFormat:@"%d/%lu",self.index+1,(unsigned long)self.imageData.count]; self.imageView.image = [UIImage imageNamed:self.imageData[self.index][@"icon"]]; self.infoLabel.text = self.imageData[self.index][@"info"]; [self changeButtonState];}- (IBAction)clickLeftButton:(UIButton *)sender { self.index--; [self reloadView];}- (IBAction)clickRightButton:(UIButton *)sender { self.index++; [self reloadView]; }-(void)changeButtonState{ self.leftButton.enabled = self.index >0; self.rightButton.enabled = self.index <4;}@end
2
0 0
- UI基础-04图片浏览器
- iOS开发UI基础—04UIButton练习之图片浏览器
- 图片浏览器--UI编程
- UI控件基础篇————简易图片浏览器
- UI组件之GridView实现图片浏览器
- IOS基础UI之(二)图片预览
- UI基础-02 按钮控制图片移动
- UI基础-图片异步下载、KVO
- IOS基础——图片浏览器
- 【Android基础】简单的本地图片浏览器
- UI基础学习04
- UI基础第四弹:简单的图片查看程序
- UI基础第十三弹: UIScrollView控件图片缩放
- UI基础第十三弹: UIScrollView控件实现图片轮播
- UI基础-03 按钮控制图片移动之transform
- UI基础 简单图片轮播器用到的知识
- ios-day02-04(图片浏览器)
- IOS基础UI之(三)手写UI和storyboard方式实现图片移动和缩放
- Shell基础之-split命令
- Shell基础之-tr命令
- 数据库分页
- Shell基础之-uniq命令
- Amazon 的 Docker - AWS ECS 是否適合作為網站部署的方案
- UI基础-04图片浏览器
- NSManagedObjectContext 积累
- mysql 更改默认数据目录
- 0.0.2 Android开发系列——Android开发基础环境
- 基于固件库的STM32F10x程序在Keil v5 MDK 下的RAM调试方法
- jquery1.9radio checkbox操作
- light oj 1422 Halloween Costumes (区间DP)
- java之--------socket编程(TCP)服务器请求与客户端
- hdu 3642(扫描线)