码迷,mamicode.com
首页 > 其他好文 > 详细

10.小项目:图片浏览器 版本1.0

时间:2015-08-01 18:53:53      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

---------------  ViewController.m  ---------------

#import <Foundation/Foundation.h>

#import "ViewController.h"


@interface ViewController ()

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

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

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

@property (nonatomic, assign) int index;

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

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

- (IBAction)nextImage;

- (IBAction)preImage;

@end


@implementation ViewController


-(void)viewDidLoad

{

    [super viewDidLoad];

    [self nextImage];

}


- (IBAction)nextImage

{

    self.index++;

    self.indexLabel.text = [NSString stringWithFormat:@"%d/5",self.index];

    

    switch (self.index) {

        case 1:

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

            self.infoLabel.text = @"在他面前,其他神马表情都弱爆了!";

            break;

        case 2:

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

            self.infoLabel.text = @"这也忒狠了";

            break;

        case 3:

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

            self.infoLabel.text = @"这小姑娘吃个牛排比杀牛还费劲啊";

            break;

        case 4:

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

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

            break;

        case 5:

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

            self.infoLabel.text = @"哥们为什么选八号呢";

            self.rightBtn.enabled = NO;

            break;

        default:

            break;

    }

    if (self.index == 1)

    {

        self.leftBtn.enabled = NO;

    }else

    {

        self.leftBtn.enabled = YES;

    }

}


- (IBAction)preImage

{

    self.index--;

    self.indexLabel.text = [NSString stringWithFormat:@"%d/5",self.index];

    self.rightBtn.enabled = YES;

    switch (self.index) {

        case 1:

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

            self.infoLabel.text = @"在他面前,其他神马表情都弱爆了!";

            self.leftBtn.enabled = NO;

            break;

        case 2:

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

            self.infoLabel.text = @"这也忒狠了";

            break;

        case 3:

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

            self.infoLabel.text = @"这小姑娘吃个牛排比杀牛还费劲啊";

            break;

        case 4:

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

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

            break;

        case 5:

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

            self.infoLabel.text = @"哥们为什么选八号呢";

            break;

        default:

            break;

    }

}


@end

 

 

 

10.小项目:图片浏览器 版本1.0

标签:

原文地址:http://www.cnblogs.com/lixiang2015/p/4694423.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!