本人小菜一个,正在学习iOS,有兴趣盆友可以加我好友,暂且不提供视频,需要的留言!
用数组的方式(懒加载)浏览图片
注意:1在翻页项目中页面不等于self.array.count不要忘记修改!
//ViewController.m
//数组浏览图片
//
//Created by11on 15/4/27.
//Copyright (c) 2015年11. All rights reserved.
//
#import"ViewController.h"
@interfaceViewController()
- (IBAction)return1Btn;//返回1
- (IBAction)returnBtn;//返回2
@property(weak,nonatomic)IBOutletUIButton*rightwardBtn;//向右
@property(weak,nonatomic)IBOutletUIButton*leftBtn;//向左
@property(weak,nonatomic)IBOutletUILabel*pagingText;//翻页
@property(weak,nonatomic)IBOutletUIImageView*pictureBtnn;//图片
@property(weak,nonatomic)IBOutletUILabel*stateText;//说明
@property(nonatomic,assign)intcalculate;//统计数据
@property(nonatomic,strong)NSArray*array;
@end
@implementationViewController
-(NSArray*)array
{
if(_array==nil)
{
NSDictionary*d1 =@{@"icon":@"biaoqingdi",@"desc":@"表启迪的表演"};
NSDictionary*d2 =@{@"icon":@"bingli",@"desc":@"病历表爱我打算的"};
NSDictionary*d3 =@{@"icon":@"chiniupa",@"desc":@"吃牛排的性感了"};
NSDictionary*d4 =@{@"icon":@"danteng",@"desc":@"蛋疼的生死搭档"};
NSDictionary*d5 =@{@"icon":@"wangba",@"desc":@"第八号"};
self.array=@[d1,d2,d3,d4,d5];
}
return_array;
}
-(IBAction)viewDidLoad
{
[superviewDidLoad];
[selfreturn1Btn];
}
-(IBAction)concourse
{
self.pagingText.text= [NSStringstringWithFormat:@"%d/%zd",self.calculate,self.array.count];
NSDictionary*da =self.array[self.calculate-1];
self.pictureBtnn.image= [UIImageimageNamed:da[@"icon"]];
self.stateText.text= da[@"desc"];
self.rightwardBtn.enabled= (self.calculate!=self.array.count);
self.leftBtn.enabled= (self.calculate!=1);
}
- (IBAction)return1Btn
{
self.calculate++;
[selfconcourse];
}
- (IBAction)returnBtn
{
self.calculate--;
[selfconcourse];
}
@end
网友评论