Skip to content

Commit

Permalink
master:合并dev,增加了App第一次安装的引导界面
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyufeng1991 committed Nov 22, 2015
2 parents 6c70b88 + 654b2f2 commit 570c595
Show file tree
Hide file tree
Showing 13 changed files with 294 additions and 17 deletions.
6 changes: 6 additions & 0 deletions Oncenote.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
714257D61C01E2330070DF76 /* GuidePageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 714257D51C01E2330070DF76 /* GuidePageViewController.m */; settings = {ASSET_TAGS = (); }; };
715CB76D1BF99B1A0079DB35 /* shareImg.png in Resources */ = {isa = PBXBuildFile; fileRef = 715CB76C1BF99B1A0079DB35 /* shareImg.png */; settings = {ASSET_TAGS = (); }; };
717902EA1BF48FC100428756 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 717902E91BF48FC100428756 /* main.m */; };
717902ED1BF48FC100428756 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 717902EC1BF48FC100428756 /* AppDelegate.m */; };
Expand Down Expand Up @@ -114,6 +115,8 @@
/* Begin PBXFileReference section */
042E519FF0D448E00C6B94EE /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
52A3A8C36BAD439F0DCC8BC9 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
714257D41C01E2330070DF76 /* GuidePageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GuidePageViewController.h; sourceTree = "<group>"; };
714257D51C01E2330070DF76 /* GuidePageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GuidePageViewController.m; sourceTree = "<group>"; };
715CB76C1BF99B1A0079DB35 /* shareImg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = shareImg.png; sourceTree = "<group>"; };
717902E51BF48FC100428756 /* Oncenote.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Oncenote.app; sourceTree = BUILT_PRODUCTS_DIR; };
717902E91BF48FC100428756 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -393,6 +396,8 @@
children = (
71BEC2881BF8BC100003F173 /* LaunchScreenViewController.h */,
71BEC2891BF8BC100003F173 /* LaunchScreenViewController.m */,
714257D41C01E2330070DF76 /* GuidePageViewController.h */,
714257D51C01E2330070DF76 /* GuidePageViewController.m */,
71A793731BF5B5F000410FFC /* LoginViewController.h */,
71A793741BF5B5F000410FFC /* LoginViewController.m */,
717902EF1BF48FC100428756 /* MainViewController.m */,
Expand Down Expand Up @@ -716,6 +721,7 @@
buildActionMask = 2147483647;
files = (
719AF3C31BFB5973009D602D /* AboutAppViewController.m in Sources */,
714257D61C01E2330070DF76 /* GuidePageViewController.m in Sources */,
71A793781BF5CDCA00410FFC /* RegisterViewController.m in Sources */,
719AF3C91BFC4CB3009D602D /* ForgetPasswordViewController.m in Sources */,
718FF3A31BF623B7009A3F6D /* AddNoteViewController.m in Sources */,
Expand Down
21 changes: 21 additions & 0 deletions Oncenote/Assets.xcassets/guidepage0.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "guidepage01.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Oncenote/Assets.xcassets/guidepage1.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "guidepage02.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Oncenote/Assets.xcassets/guidepage2.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "guidepage03.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Oncenote/Assets.xcassets/guidepage3.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "guidepage04.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 29 additions & 1 deletion Oncenote/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,35 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="GJR-RC-sUK" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="212" y="304"/>
<point key="canvasLocation" x="-328" y="312"/>
</scene>
<!--Guide Page View Controller-->
<scene sceneID="30T-uJ-1X2">
<objects>
<viewController storyboardIdentifier="GuidePageViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="QrW-en-pfa" customClass="GuidePageViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="hiu-ti-Dpg">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="I4B-ec-rPI">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<connections>
<outlet property="delegate" destination="QrW-en-pfa" id="dOI-tV-HtQ"/>
</connections>
</scrollView>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="guidepageScrollView" destination="I4B-ec-rPI" id="KKO-3j-VHL"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cyP-vV-T6U" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="214" y="316"/>
</scene>
<!--Login View Controller-->
<scene sceneID="YGY-iR-8wz">
Expand Down
13 changes: 13 additions & 0 deletions Oncenote/GuidePageViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// GuidePageViewController.h
// Oncenote
//
// Created by chenyufeng on 15/11/22.
// Copyright © 2015年 chenyufengweb. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface GuidePageViewController : UIViewController

@end
130 changes: 130 additions & 0 deletions Oncenote/GuidePageViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@

//
// GuidePageViewController.m
// Oncenote
//
// Created by chenyufeng on 15/11/22.
// Copyright © 2015年 chenyufengweb. All rights reserved.
//

#import "GuidePageViewController.h"
#import "AllUtils.h"

#define UISCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)

@interface GuidePageViewController ()<UIScrollViewDelegate,UIPageViewControllerDelegate>

@property (weak, nonatomic) IBOutlet UIScrollView *guidepageScrollView;

@property(nonatomic,strong)UIPageControl *pageControl;


@end

@implementation GuidePageViewController

- (void)viewDidLoad {
[super viewDidLoad];

NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:@"exist" forKey:@"guidepage"];

self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake([[UIScreen mainScreen] bounds].size.width / 2 - 50, [[UIScreen mainScreen] bounds].size.height - 50, 100, 20)];
self.pageControl.numberOfPages = 5;
[self.view addSubview:self.pageControl];

[self setGuidePageScrollViewFrame];
}

#pragma mark - 设置控件的位置大小
- (void)setGuidePageScrollViewFrame{

self.guidepageScrollView.contentSize = CGSizeMake([[UIScreen mainScreen] bounds].size.width * 5, [[UIScreen mainScreen] bounds].size.height);
[self.guidepageScrollView setUserInteractionEnabled:true];
[self.guidepageScrollView setScrollEnabled:true];
[self.guidepageScrollView setPagingEnabled:true];
[self.guidepageScrollView setShowsHorizontalScrollIndicator:false];
[self.guidepageScrollView setShowsVerticalScrollIndicator:false];
[self.guidepageScrollView setBounces:false];

[self setGuidePageImageFrame];

}

- (void)setGuidePageImageFrame{

for (int i = 0; i < 4; i++) {

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake([[UIScreen mainScreen] bounds].size.width * i, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];

[imageView setUserInteractionEnabled:true];

[imageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"guidepage%d",i]]];

[self.guidepageScrollView addSubview:imageView ];


}


UIView *view = [[UIView alloc] initWithFrame:CGRectMake([[UIScreen mainScreen] bounds].size.width * 4, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)];
[view setUserInteractionEnabled:true];
[view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"guidepage0.png"]]];


UIButton *loginButton = [[UIButton alloc] initWithFrame:CGRectMake((UISCREEN_WIDTH - 200) / 3, 400, 100, 30)];
[loginButton setTitle:@"登录" forState:UIControlStateNormal];
[loginButton.layer setBorderColor:[UIColor whiteColor].CGColor];
[loginButton.layer setBorderWidth:0.5];
[loginButton.layer setMasksToBounds:true];
[loginButton addTarget:self action:@selector(loginButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

UIButton *registerButton = [[UIButton alloc] initWithFrame:CGRectMake((UISCREEN_WIDTH - 200) / 3 + (UISCREEN_WIDTH - 200) / 3 + 100, 400, 100, 30)];
[registerButton setTitle:@"注册" forState:UIControlStateNormal];
[registerButton.layer setBorderColor:[UIColor whiteColor].CGColor];
[registerButton.layer setBorderWidth:0.5];
[registerButton.layer setMasksToBounds:true];
[registerButton addTarget:self action:@selector(registerButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

[view addSubview:loginButton];
[view addSubview:registerButton];

[self.guidepageScrollView addSubview:view];


}





#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{

CGFloat offsetWidth = self.guidepageScrollView.contentOffset.x;
int pageNum = offsetWidth / [[UIScreen mainScreen] bounds].size.width;
self.pageControl.currentPage = pageNum;



}

#pragma mark - 所有按钮的点击事件
- (void)loginButtonPressed:(id)sender{

[AllUtils jumpToViewController:@"LoginViewController" contextViewController:self handler:nil];

}

- (void)registerButtonPressed:(id)sender{

[AllUtils jumpToViewController:@"RegisterViewController" contextViewController:self handler:nil];
}


@end





48 changes: 32 additions & 16 deletions Oncenote/LaunchScreenViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,44 @@ - (void)viewDidLoad {


- (void)viewDidAppear:(BOOL)animated{

[super viewDidAppear:animated];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

if ([userDefaults objectForKey:@"username"] != nil && [userDefaults objectForKey:@"Password"] != nil ) {
//直接跳到主界面;
NSLog(@"直接跳到主界面");

AppDelegate *globalApp = [[UIApplication sharedApplication] delegate];
globalApp.GLOBAL_USERNAME = [userDefaults objectForKey:@"username"];
globalApp.GLOBAL_USERID = [userDefaults objectForKey:@"userId"];
globalApp.GLOBAL_NICKNAME = [userDefaults objectForKey:@"nickname"];
globalApp.GLOBAL_PASSWORD = [userDefaults objectForKey:@"Password"];

[AllUtils jumpToViewController:@"MainViewController" contextViewController:self handler:nil];


if ([userDefaults objectForKey:@"guidepage"] == nil) {
//如果这个首选项为空的话,表示用户是刚刚安装App,所以要显示引导页;
//直接跳到引导页;
[AllUtils jumpToViewController:@"GuidePageViewController" contextViewController:self handler:nil];
}else{
NSLog(@"跳到登录界面");
//跳到登录界面;
[AllUtils jumpToViewController:@"LoginViewController" contextViewController:self handler:nil];

//不是第一次安装;
if ([userDefaults objectForKey:@"username"] != nil && [userDefaults objectForKey:@"Password"] != nil ) {
//存储了用户名密码,直接跳到主界面;
NSLog(@"直接跳到主界面");

AppDelegate *globalApp = [[UIApplication sharedApplication] delegate];
globalApp.GLOBAL_USERNAME = [userDefaults objectForKey:@"username"];
globalApp.GLOBAL_USERID = [userDefaults objectForKey:@"userId"];
globalApp.GLOBAL_NICKNAME = [userDefaults objectForKey:@"nickname"];
globalApp.GLOBAL_PASSWORD = [userDefaults objectForKey:@"Password"];

[AllUtils jumpToViewController:@"MainViewController" contextViewController:self handler:nil];

}else{
NSLog(@"跳到登录界面");
//跳到登录界面;
[AllUtils jumpToViewController:@"LoginViewController" contextViewController:self handler:nil];

}

}






}


Expand Down

0 comments on commit 570c595

Please sign in to comment.