iOS新特性引导页

有一个注意点:

获取版本号
个叫做Version,一个叫做Build,这两个值都可以在Xcode 中选中target,点击“Summary”后看到。 Version在plist文件中的key是“CFBundleShortVersionString”,和AppStore上的版本号保持一致,Build在plist中的key是“CFBundleVersion”,代表build的版本号,该值每次build之后都应该增加1。这两个值都可以在程序中通过下面的代码获得:
 
1.Version
NSString *key = @"CFBundleShortVersionString";
2.build
NSString *key =@"CFBundleVersion";

1.在AppDelegate.m

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; NSString *key = @"CFBundleShortVersionString";
//上一个版本号,存沙盒
NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:key];
//当前版本号
NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
NSLog(@"前面%@----当前%@",lastVersion,currentVersion); if ([currentVersion isEqualToString:lastVersion]) {
self.window.rootViewController = [ViewController new]; //为真表示已有文件 曾经进入过主页
}else{
self.window.rootViewController =[LGFNEWfeatureViewController new];//为假表示没有文件,没有进入过主页
[[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
[[NSUserDefaults standardUserDefaults] synchronize];
}
[self.window makeKeyAndVisible]; return YES;
}

2.在新特性的VC中:

 #import "LGFNEWfeatureViewController.h"
#import "ViewController.h" #define LGFNEWFeatureCount 3
@interface LGFNEWfeatureViewController ()<UIScrollViewDelegate>
@property(nonatomic,strong)UIScrollView *scrollView; @property(nonatomic,strong)UIPageControl *pageControl; @end @implementation LGFNEWfeatureViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self setScrollerView];
} -(void)setScrollerView{
self.scrollView = [UIScrollView new];
_scrollView.frame = self.view.bounds;
_scrollView.contentSize = CGSizeMake(LGFNEWFeatureCount *self.view.frame.size.width, );
_scrollView.bounces = NO;
_scrollView.pagingEnabled = YES;
_scrollView.showsHorizontalScrollIndicator =NO;
[self.view addSubview:_scrollView];
for (int i =; i<LGFNEWFeatureCount; i++) {
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width*i, , self.view.frame.size.width, self.view.frame.size.height)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d",i+]];
[_scrollView addSubview:imageView];
if (i == LGFNEWFeatureCount-) {
[self setupLastImageView:imageView];
}
}
_scrollView.delegate = self; self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(, self.view.frame.size.height-, self.view.frame.size.width-,)];
_pageControl.numberOfPages = LGFNEWFeatureCount;
_pageControl.currentPageIndicatorTintColor =[UIColor orangeColor];
_pageControl.userInteractionEnabled = NO;
[self.view addSubview:_pageControl]; } -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
self.pageControl.currentPage = self.scrollView.contentOffset.x/self.view.frame.size.width;
} -(void)setupLastImageView:(UIImageView*)imageView{
//开启用户交互
imageView.userInteractionEnabled = YES;
//1.分享
UIButton *sharedBtn =[[UIButton alloc] initWithFrame:CGRectMake(, self.view.frame.size.height-, self.view.frame.size.width*0.5,self.view.frame.size.height*0.3)]; [sharedBtn setImage:[UIImage imageNamed:@"shared"] forState:UIControlStateNormal];
[sharedBtn setImage:[UIImage imageNamed:@"sharedselect"] forState:UIControlStateSelected];
[sharedBtn setTitle:@"分享给大家" forState:UIControlStateNormal];
sharedBtn.titleEdgeInsets = UIEdgeInsetsMake(, , , );
sharedBtn.titleLabel.font = [UIFont systemFontOfSize:];
[sharedBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[sharedBtn addTarget:self action:@selector(sharedBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:sharedBtn]; //2.开始程序首页
UIButton *startBtn = [[UIButton alloc] initWithFrame:CGRectMake(, self.view.frame.size.height*0.88, self.view.frame.size.width*0.4,self.view.frame.size.height*0.05)];
startBtn.layer.cornerRadius = 12.0f;
startBtn.layer.masksToBounds =YES;
startBtn.backgroundColor = [UIColor orangeColor];
[startBtn setTitle:@"开启APP之旅" forState:UIControlStateNormal];
[startBtn addTarget:sharedBtn action:@selector(startBtnClick) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:startBtn]; } -(void)sharedBtnClick:(UIButton *)sharedBtn{
sharedBtn.selected = !sharedBtn.selected;
} -(void)startBtnClick{
UIWindow *win =[UIApplication sharedApplication].keyWindow;
win.rootViewController = [ViewController new];
}
上一篇:转载 Javascript继承两种形式详解


下一篇:centos Linux系统日常管理1 cpuinfo cpu核数 命令 w, vmstat, uptime ,top ,kill ,ps ,free,netstat ,sar, ulimit ,lsof ,pidof 第十四节课