简易图片浏览器

//

//  ViewController.m

//  图片浏览器

//

//  Created by 罗普生 on 14/12/4.

//  Copyright (c) 2014 luopusheng. All rights reserved.

//


#import "ViewController.h"


@interface ViewController ()

- (IBAction)change:(UIButton *)sender;

@property (weak, nonatomic) IBOutlet UILabel *top;

@property (weak, nonatomic) IBOutlet UIImageView *show;

@property (weak, nonatomic) IBOutlet UILabel *dwon;

@property (weak, nonatomic) IBOutlet UIButton *left;

@property (weak, nonatomic) IBOutlet UIButton *right;


@property (nonatomic,assign) int index;

@property (nonatomic,strong) NSArray *imgDate;

@end


@implementation ViewController


-(void)viewDidLoad{

    [super viewDidLoad];

    //初始化数据

    NSMutableDictionary *img1 = [NSMutableDictionary dictionary];

    img1[@"icon"] = @"biaoqingdi";

    img1[@"desc"] = @"拐子,又扯到蛋了?";

    NSMutableDictionary *img2 = [NSMutableDictionary dictionary];

    img2[@"icon"] = @"wangba";

    img2[@"desc"] = @"大锤,为什么选8号?";

    NSMutableDictionary *img3 = [NSMutableDictionary dictionary];

    img3[@"icon"] = @"bingli";

    img3[@"desc"] = @"这也太狠了!";

    NSMutableDictionary *img4 = [NSMutableDictionary dictionary];

    img4[@"icon"] = @"chiniupa";

    img4[@"desc"] = @"哎,真费劲!";

    NSMutableDictionary *img5 = [NSMutableDictionary dictionary];

    img5[@"icon"] = @"danteng";

    img5[@"desc"] = @"~~~~";

    

    _imgDate = [NSArray arrayWithObjects:img1, img2, img3,img4,img5, nil];

    [self changeDate];

}


#pragma mark changDate

-(void)changeDate{

 //改变数据

    _top.text = [NSString stringWithFormat:@"%d/%lu",_index + 1,self.imgDate.count];

 //取出index对应的字典数据

    NSDictionary *imaDic = _imgDate[_index];

     NSLog(@"%d-------------,%@",_index,imaDic);

 //设置图片

    _show.image = [UIImage imageNamed:imaDic[@"icon"]];

 //设置描述

    _dwon.text = imaDic[@"desc"];

 //设置按钮状态

    _left.enabled = _index != 0;

    _right.enabled = _index != _imgDate.count - 1;


}


- (IBAction)change:(UIButton *)sender {

    switch (sender.tag) {

        case 1:

            _index --;

            [self changeDate];

            break;

            

        default:

            _index ++;

            [self changeDate];

            break;

    }

}

@end




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值