Skip to content

Commit

Permalink
CoreNewFeatureVC
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlinFeng committed Apr 27, 2015
1 parent 18aedfe commit 420359e
Show file tree
Hide file tree
Showing 11 changed files with 510 additions and 10 deletions.
52 changes: 52 additions & 0 deletions CoreNewFeatureVC.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
89335FBA1AEE00CC00BC444B /* UIView+Masony.m in Sources */ = {isa = PBXBuildFile; fileRef = 89335FAF1AEE00CC00BC444B /* UIView+Masony.m */; };
89335FBD1AEE022C00BC444B /* NewFeatureScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 89335FBC1AEE022C00BC444B /* NewFeatureScrollView.m */; };
89335FC01AEE057C00BC444B /* NewFeatureImageV.m in Sources */ = {isa = PBXBuildFile; fileRef = 89335FBF1AEE057C00BC444B /* NewFeatureImageV.m */; };
89335FC51AEE0AD200BC444B /* UIApplication+Extend.m in Sources */ = {isa = PBXBuildFile; fileRef = 89335FC41AEE0AD200BC444B /* UIApplication+Extend.m */; };
89335FD01AEE0B8B00BC444B /* NSString+File.m in Sources */ = {isa = PBXBuildFile; fileRef = 89335FCD1AEE0B8B00BC444B /* NSString+File.m */; };
89335FD11AEE0B8B00BC444B /* CoreArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = 89335FCF1AEE0B8B00BC444B /* CoreArchive.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -86,6 +89,12 @@
89335FBC1AEE022C00BC444B /* NewFeatureScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewFeatureScrollView.m; sourceTree = "<group>"; };
89335FBE1AEE057C00BC444B /* NewFeatureImageV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewFeatureImageV.h; sourceTree = "<group>"; };
89335FBF1AEE057C00BC444B /* NewFeatureImageV.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewFeatureImageV.m; sourceTree = "<group>"; };
89335FC31AEE0AD200BC444B /* UIApplication+Extend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIApplication+Extend.h"; sourceTree = "<group>"; };
89335FC41AEE0AD200BC444B /* UIApplication+Extend.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIApplication+Extend.m"; sourceTree = "<group>"; };
89335FCC1AEE0B8B00BC444B /* NSString+File.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+File.h"; sourceTree = "<group>"; };
89335FCD1AEE0B8B00BC444B /* NSString+File.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+File.m"; sourceTree = "<group>"; };
89335FCE1AEE0B8B00BC444B /* CoreArchive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreArchive.h; sourceTree = "<group>"; };
89335FCF1AEE0B8B00BC444B /* CoreArchive.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CoreArchive.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -168,6 +177,7 @@
89335F881AEDFF2000BC444B /* CoreNewFeatureVC */ = {
isa = PBXGroup;
children = (
89335FC11AEE0A9300BC444B /* Category */,
89335F891AEDFF2000BC444B /* Controller */,
89335F8A1AEDFF2000BC444B /* Model */,
89335F8B1AEDFF2000BC444B /* View */,
Expand Down Expand Up @@ -207,6 +217,7 @@
89335F921AEE00BF00BC444B /* FrameWorks */ = {
isa = PBXGroup;
children = (
89335FCA1AEE0B8B00BC444B /* CoreArchive */,
89335F931AEE00CC00BC444B /* Masonry */,
);
path = FrameWorks;
Expand Down Expand Up @@ -261,6 +272,42 @@
path = Masonry;
sourceTree = "<group>";
};
89335FC11AEE0A9300BC444B /* Category */ = {
isa = PBXGroup;
children = (
89335FC21AEE0AD200BC444B /* UIApplication */,
);
path = Category;
sourceTree = "<group>";
};
89335FC21AEE0AD200BC444B /* UIApplication */ = {
isa = PBXGroup;
children = (
89335FC31AEE0AD200BC444B /* UIApplication+Extend.h */,
89335FC41AEE0AD200BC444B /* UIApplication+Extend.m */,
);
path = UIApplication;
sourceTree = "<group>";
};
89335FCA1AEE0B8B00BC444B /* CoreArchive */ = {
isa = PBXGroup;
children = (
89335FCB1AEE0B8B00BC444B /* Category */,
89335FCE1AEE0B8B00BC444B /* CoreArchive.h */,
89335FCF1AEE0B8B00BC444B /* CoreArchive.m */,
);
path = CoreArchive;
sourceTree = "<group>";
};
89335FCB1AEE0B8B00BC444B /* Category */ = {
isa = PBXGroup;
children = (
89335FCC1AEE0B8B00BC444B /* NSString+File.h */,
89335FCD1AEE0B8B00BC444B /* NSString+File.m */,
);
path = Category;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -375,9 +422,12 @@
89335FB31AEE00CC00BC444B /* MASConstraintMaker.m in Sources */,
89335FB71AEE00CC00BC444B /* NSArray+MASAdditions.m in Sources */,
89335FC01AEE057C00BC444B /* NewFeatureImageV.m in Sources */,
89335FD01AEE0B8B00BC444B /* NSString+File.m in Sources */,
89335FB21AEE00CC00BC444B /* MASConstraint.m in Sources */,
89335FD11AEE0B8B00BC444B /* CoreArchive.m in Sources */,
89335FB41AEE00CC00BC444B /* MASLayoutConstraint.m in Sources */,
89335F651AEDFEE800BC444B /* main.m in Sources */,
89335FC51AEE0AD200BC444B /* UIApplication+Extend.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -576,6 +626,7 @@
89335F841AEDFEE800BC444B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
89335F851AEDFEE800BC444B /* Build configuration list for PBXNativeTarget "CoreNewFeatureVCTests" */ = {
isa = XCConfigurationList;
Expand All @@ -584,6 +635,7 @@
89335F871AEDFEE800BC444B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
20 changes: 15 additions & 5 deletions CoreNewFeatureVC/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,24 @@ @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

self.window = window;
NewFeatureModel *m1 = [NewFeatureModel model:[UIImage imageNamed:@"f1"]];

NewFeatureModel *m2 = [NewFeatureModel model:[UIImage imageNamed:@"f2"]];

NewFeatureModel *m3 = [NewFeatureModel model:[UIImage imageNamed:@"f3"]];
if([CoreNewFeatureVC canShowNewFeature]){
NewFeatureModel *m1 = [NewFeatureModel model:[UIImage imageNamed:@"f1"]];

NewFeatureModel *m2 = [NewFeatureModel model:[UIImage imageNamed:@"f2"]];

NewFeatureModel *m3 = [NewFeatureModel model:[UIImage imageNamed:@"f3"]];

window.rootViewController = [CoreNewFeatureVC newFeatureVCWithModels:@[m1,m2,m3]];
}else{
UIViewController *vc = [[UIViewController alloc] init];
vc.view.backgroundColor = [UIColor brownColor];
window.rootViewController = vc;
}

window.rootViewController = [CoreNewFeatureVC newFeatureVCWithModels:@[m1,m2,m3]];


[window makeKeyAndVisible];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// UIApplication+Extend.h
// Carpenter
//
// Created by 冯成林 on 15/4/24.
// Copyright (c) 2015年 冯成林. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIApplication (Extend)


/*
* 当前程序的版本号
*/
@property (nonatomic,copy,readonly) NSString *version;


@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// UIApplication+Extend.m
// Carpenter
//
// Created by 冯成林 on 15/4/24.
// Copyright (c) 2015年 冯成林. All rights reserved.
//

#import "UIApplication+Extend.h"

@implementation UIApplication (Extend)


/*
* 当前程序的版本号
*/
-(NSString *)version{

//系统直接读取的版本号
NSString *versionValueStringForSystemNow=[[NSBundle mainBundle].infoDictionary valueForKey:(NSString *)kCFBundleVersionKey];

return versionValueStringForSystemNow;
}



@end
9 changes: 9 additions & 0 deletions CoreNewFeatureVC/CoreNewFeatureVC/CoreNewFeatureVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,13 @@
+(instancetype)newFeatureVCWithModels:(NSArray *)models;



/*
* 是否应该显示版本新特性界面
*/
+(BOOL)canShowNewFeature;




@end
47 changes: 44 additions & 3 deletions CoreNewFeatureVC/CoreNewFeatureVC/CoreNewFeatureVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
#import "UIView+Masony.h"
#import "NewFeatureScrollView.h"
#import "NewFeatureImageV.h"
#import "UIApplication+Extend.h"
#import "CoreArchive.h"


NSString *const NewFeatureVersionKey = @"NewFeatureVersionKey";

@interface CoreNewFeatureVC ()


Expand Down Expand Up @@ -45,9 +49,26 @@ -(void)viewDidLoad{

//控制器准备
[self vcPrepare];

//显示了版本新特性,保存版本号
[self saveVersion];
}


/*
* 显示了版本新特性,保存版本号
*/
-(void)saveVersion{

//系统直接读取的版本号
NSString *versionValueStringForSystemNow=[UIApplication sharedApplication].version;

//保存版本号
[CoreArchive setStr:versionValueStringForSystemNow key:NewFeatureVersionKey];
}



/*
* 控制器准备
*/
Expand Down Expand Up @@ -109,13 +130,33 @@ -(void)gestureAction:(UITapGestureRecognizer *)tap{
tapView.userInteractionEnabled = NO;

if(UIGestureRecognizerStateEnded == tap.state) [self dismiss];


}

-(void)dismiss{
NSLog(@"消失");
}


/*
* 是否应该显示版本新特性页面
*/
+(BOOL)canShowNewFeature{

//系统直接读取的版本号
NSString *versionValueStringForSystemNow=[UIApplication sharedApplication].version;

//读取本地版本号
NSString *versionLocal = [CoreArchive strForKey:NewFeatureVersionKey];

if(versionLocal!=nil && [versionValueStringForSystemNow isEqualToString:versionLocal]){//说明有本地版本记录,且和当前系统版本一致

return NO;

}else{//无本地版本记录或本地版本记录与当前系统版本不一致

//保存
[CoreArchive setStr:versionValueStringForSystemNow key:NewFeatureVersionKey];

return YES;
}
}
@end
42 changes: 42 additions & 0 deletions CoreNewFeatureVC/FrameWorks/CoreArchive/Category/NSString+File.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// NSString+File.h
// CoreCategory
//
// Created by 成林 on 15/4/6.
// Copyright (c) 2015年 沐汐. All rights reserved.
//

#import <Foundation/Foundation.h>



@interface NSString (File)


/*
* document根文件夹
*/
+(NSString *)documentFolder;


/*
* caches根文件夹
*/
+(NSString *)cachesFolder;




/**
* 生成子文件夹
*
* 如果子文件夹不存在,则直接创建;如果已经存在,则直接返回
*
* @param subFolder 子文件夹名
*
* @return 文件夹路径
*/
-(NSString *)createSubFolder:(NSString *)subFolder;


@end
62 changes: 62 additions & 0 deletions CoreNewFeatureVC/FrameWorks/CoreArchive/Category/NSString+File.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// NSString+File.m
// CoreCategory
//
// Created by 成林 on 15/4/6.
// Copyright (c) 2015年 沐汐. All rights reserved.
//

#import "NSString+File.h"

@implementation NSString (File)

/*
* document根文件夹
*/
+(NSString *)documentFolder{

return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
}



/*
* caches根文件夹
*/
+(NSString *)cachesFolder{

return [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
}





/**
* 生成子文件夹
*
* 如果子文件夹不存在,则直接创建;如果已经存在,则直接返回
*
* @param subFolder 子文件夹名
*
* @return 文件夹路径
*/
-(NSString *)createSubFolder:(NSString *)subFolder{

NSString *subFolderPath=[NSString stringWithFormat:@"%@/%@",self,subFolder];

BOOL isDir = NO;

NSFileManager *fileManager = [NSFileManager defaultManager];

BOOL existed = [fileManager fileExistsAtPath:subFolderPath isDirectory:&isDir];

if ( !(isDir == YES && existed == YES) )
{
[fileManager createDirectoryAtPath:subFolderPath withIntermediateDirectories:YES attributes:nil error:nil];
}

return subFolderPath;
}

@end
Loading

0 comments on commit 420359e

Please sign in to comment.