欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS開(kāi)發(fā)實(shí)現(xiàn)圖片瀏覽功能

 更新時(shí)間:2022年01月27日 13:51:08   作者:Qu_qipa  
這篇文章主要為大家詳細(xì)介紹了iOS開(kāi)發(fā)實(shí)現(xiàn)圖片瀏覽功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了iOS實(shí)現(xiàn)圖片瀏覽功能的具體代碼,供大家參考,具體內(nèi)容如下

這是整體的效果圖:

其中main.stroyboard中的控件有2個(gè)button,2個(gè)label,一個(gè)imageView。
設(shè)置他們的位置大小和背景顏色和圖片。
讓main.storyboard連接ViewController.m

下面是它的代碼:

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *topLabel;
@property (weak, nonatomic) IBOutlet UILabel *descLabel;
@property (weak, nonatomic) IBOutlet UIButton *leftBtn;
@property (weak, nonatomic) IBOutlet UIButton *rightBtn;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@property (nonatomic, assign) int index;

@property (nonatomic, strong) NSArray *imageDicts;

@end

@implementation ViewController

- (NSArray *)imageDicts
{
? ? if (!_imageDicts) {

? ? ? ? NSString *path = [[NSBundle mainBundle] pathForResource:@"imageDate.plist" ofType:nil];
? ? ? ? _imageDicts = [NSArray arrayWithContentsOfFile:path];
? ? }
? ? return _imageDicts;
}

- (IBAction)leftBtnOnClick:(UIButton *)sender {
? ? self.index --;

? ? [self btnClickChange];

}
- (IBAction)rightBtnOnClick:(id)sender {
? ? self.index ++;

? ? [self btnClickChange];
}

- (void)btnClickChange
{
? ? self.topLabel.text = [NSString stringWithFormat:@"%d/%d", (self.index + 1), self.imageDicts.count];


? ? self.descLabel.text = self.imageDicts[self.index][@"description"];

? ? self.imageView.image = [UIImage imageNamed:self.imageDicts[self.index][@"name"]];

? ? self.leftBtn.enabled = (self.index != 0);
? ? self.rightBtn.enabled = (self.index != 4);
}

- (void)viewDidLoad {
? ? [super viewDidLoad];
? ? // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
? ? [super didReceiveMemoryWarning];
? ? // Dispose of any resources that can be recreated.
}

@end

這樣就完成了一個(gè)簡(jiǎn)單的圖片瀏覽的應(yīng)用。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論