//
// ViewController.m
//
//
// Created by 张艳锋 on 15/8/26.
// Copyright (c) 2015年 张艳锋. All rights reserved.
//
#import "ViewController.h"
#import "LBZPrefixHeader.pch"
#import "LBZModelDataAll.h"
#import "AchievementViewController.h"
#import "ChartsViewController.h"
@interface ViewController ()
{
BOOL isOut;
}
- (IBAction)doAchievementButton:(id)sender;
- (IBAction)doChartsButton:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// NSLog(@"%@",[LBZModelDataAll dataArrayFromModel:poet_list]);
// NSLog(@"%@",[LBZModelDataAll dataDetailFromModel:poet_list andDataNum:0 andNSString:nick_desc]);
//解析数据
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstLanch"]) {
// NSLog(@"程序首次安装启动");
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLanch"];
[self makeLaunchView];
}
else{
// NSLog(@"程序不是首次安装启动");
}
self.navigationController.navigationBarHidden = YES;
// NSString *str = [LBZModelDataAll dataDetailFromModel:poet_list andDataNum:0 andNSString:nick_desc];
// NSLog(@"%@",str);
//NSString *path=[[NSBundle mainBundle]pathForResource:@"0" ofType:@"jpg"];
// NSLog(@"%@",path);
}
-(void)makeLaunchView{
//张艳锋,引导页,【四张图片】
UIScrollView *myScrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,568, 320)];//显示框大小
myScrollview.tag=121;
myScrollview.backgroundColor=[UIColor redColor];
myScrollview.contentSize=CGSizeMake(568*4, 320);//有效显示区域
myScrollview.delegate=self;//添加代理
//添加图片组
for (int i=0; i<4; i++) {
UIImageView *imageview1=[[UIImageView alloc]initWithFrame:CGRectMake(568*i, 0, 568, 320)];//设置图片显示大小
NSString *imageName=[NSString stringWithFormat:@"%d.jpg",i];
imageview1.image=[UIImage imageNamed:imageName];
[myScrollview addSubview:imageview1];
}
myScrollview.pagingEnabled=YES;//按页翻动
[self.view addSubview:myScrollview];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
//这里是在滚动的时候判断 我滚动到哪张图片了,如果滚动到了最后一张图片,那么
//如果在往下面滑动的话就该进入到主界面了,我这里利用的是偏移量来判断的,当
//一共五张图片,所以当图片全部滑完后 又像后多滑了30 的时候就做下一个动作
if (scrollView.contentOffset.x>4*320+30) {
isOut=YES;//这是我声明的一个全局变量Bool 类型的,初始值为no,当达到我需求的条件时将值改为yes
}
}
//停止滑动
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
//判断isout为真 就要进入主界面了
if (isOut) {
//这里添加了一个动画,(可根据个人喜好)
[UIView animateWithDuration:1.5 animations:^{
scrollView.alpha=0;//让scrollview 渐变消失
}completion:^(BOOL finished) {
[scrollView removeFromSuperview];//将scrollView移除
// [self gotoMain];//进入主界面
NSLog(@"sdfdsdfd");
NSString *dataPlistPath = @"/Users/scjy/Desktop/LIBAOZHENG0826/dataPlist.plist";
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:dataPlistPath]) {
//如果文件不存在,创建文件[fileManager createFileAtPath:dataPlistPath contents:nil attributes:nil];
}
NSArray *clickPoetry = [NSArray array];
NSDictionary *Dicinit = @{@"userName":@"123",@"ID":@"999",@"clickPoetry":clickPoetry};
[Dicinit writeToFile:dataPlistPath atomically:YES];
} ];
}
}
- (IBAction)doAchievementButton:(id)sender {
NSLog(@"chengjiuyemian");
//ZYF控制权转换
AchievementViewController *achievementVC=[[AchievementViewController alloc]initWithNibName:@"AchievementViewController" bundle:nil];
[self presentViewController:achievementVC animated:YES completion:nil];//转换页面
}
- (IBAction)doChartsButton:(id)sender {
NSLog(@"paihangyemian");
//ZYF控制权转换
ChartsViewController *chartsVC=[[ChartsViewController alloc]initWithNibName:@"ChartsViewController" bundle:nil];
[self presentViewController:chartsVC animated:YES completion:nil];//转换页面
}
@end