首页 > 代码库 > iOS开发-图片浏览器(优化)

iOS开发-图片浏览器(优化)

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1e9421 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; min-height: 21.0px } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #c81b13 } p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3c828b } p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #21961c } p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px "PingFang SC"; color: #21961c } p.p7 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #c42275 } p.p8 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000 } p.p9 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3e1e81 } p.p10 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #294c50 } p.p11 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px "PingFang SC"; color: #1e9421 } p.p12 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #539aa4 } span.s1 { } span.s2 { font: 18.0px "PingFang SC" } span.s3 { color: #822d0f } span.s4 { color: #c42275 } span.s5 { color: #000000 } span.s6 { font: 18.0px Menlo } span.s7 { color: #6122ae } span.s8 { color: #539aa4 } span.s9 { color: #0435ff } span.s10 { color: #703daa } span.s11 { color: #c81b13 } span.s12 { color: #3e1e81 } span.s13 { font: 18.0px "PingFang SC"; color: #c81b13 } span.s14 { font: 18.0px Menlo; color: #000000 }</style>

//

//  ViewController.m

//  19-图片浏览器

//

//  Created by hongqiangli on 2017/7/31.

//  Copyright ? 2017 信和惠民投资管理(北京)有限公司. All rights reserved.

//

 

#import "ViewController.h"

 

@interface ViewController ()

 

/**

 记录当前的索引号

 */

@property(nonatomic,assign)int index;

 

/**

 上一张

 */

- (IBAction)previous;

 

/**

 下一张

 */

- (IBAction)next;

 

/**

 描述

 */

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

 

/**

 上一个按钮

 */

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

 

/**

 下一个按钮

 */

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

 

/**

 索引label

 */

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

 

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

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    [self changData];

    

}

 

/**

 点击上一张

 */

- (IBAction)previous {

    _index--;

    [self changData];

}

 

/**

 下一张

 */

- (IBAction)next {

    _index++;

    [self changData];

    

}

 

- (void)changData{

    

    switch (_index) {

        case 0:

            _noLabel.text = @"1/5";

            _mainImageView.image = [UIImage imageNamed:@"biaoqingdi"];

            _descLabel.text = @"在他前面,其他什么表情都弱爆了!";

            break;

        case 1:

            _noLabel.text = @"2/5";

            _mainImageView.image = [UIImage imageNamed:@"wangba"];

            _descLabel.text = @"哥们为什么选择八号呢";

            break;

        case 2:

            _noLabel.text = @"3/5";

            _mainImageView.image = [UIImage imageNamed:@"bingli"];

            _descLabel.text = @"这也忒狠了";

            break;

        case 3:

            _noLabel.text = @"4/5";

            _mainImageView.image = [UIImage imageNamed:@"chiniupa"];

            _descLabel.text = @"这个小姑娘吃个牛排比杀牛还费劲呢";

            break;

        case 4:

            _noLabel.text = @"5/5";

            _mainImageView.image = [UIImage imageNamed:@"danteng"];

            _descLabel.text = @"亲,你能改下你的网名么?哈哈";

            break;

            

        default:

            break;

    }

    

    //判断按钮能不能点击

    _previousBtn.enabled = (_index != 0);

    _nextBtn.enabled = (_index != 4);

 

}

@end

iOS开发-图片浏览器(优化)