ios开发新特性页面加载
//取出版本关键字
NSString * key =(NSString * )kCFBundleVersionKey;
//取到新版本
NSString * version = [NSBundle mainBundle].infoDictionary[key];
//取到旧版本
NSString * saveVersion =[[NSUserDefaults standardUserDefaults] valueForKey:key];
// NSLog(@"%@",version);
// NSLog(@"****************") ;
// NSLog(@"%@",saveVersion);
//
//版本一样:已经下载过了不需要更新新特性
if ([version isEqualToString:saveVersion]) {
MyTabBarViewController * myTabBar =[[MyTabBarViewController alloc]init];
self.window.rootViewController=myTabBar;
}
else{
// //第一次运行或者更新版本
//存入旧版本
NSString * version = [NSBundle mainBundle].infoDictionary[key];
//将version存入沙盒中
[[NSUserDefaults standardUserDefaults] setValue:version forKey:key];
//快速写入沙盒
[[NSUserDefaults standardUserDefaults] synchronize];
[NSThread sleepForTimeInterval:0.7];
WelcomeViewController * welcome = [[WelcomeViewController alloc]init];
self.window.rootViewController =welcome;
// }
}
//新特性展示
#import "WelcomeViewController.h"
#import "MyTabBarViewController.h"
#define kImageCount 4
@interface WelcomeViewController ()<UIScrollViewDelegate>
@property (nonatomic,strong)UIScrollView * scroll;
@property (nonatomic,strong)UIPageControl * pageControl;
@end
@implementation WelcomeViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self creatScrollView];
[self setterImageview];
// Do any additional setup after loading the view.
}
- (void)creatScrollView{
_scroll =[[UIScrollView alloc]init];
_scroll.frame=[UIScreen mainScreen].bounds;
[self.view addSubview:_scroll];
}
- (void)setterImageview{
CGFloat width = self.view.bounds.size.width;
CGFloat height = self.view.bounds.size.height;
for (NSInteger i = 0; i < kImageCount; i++) {
UIImageView * imgView =[[UIImageView alloc]init];
[imgView setFrame:CGRectMake(i*width, 0, width, height)];
NSString * imgName =[NSString stringWithFormat:@"splash_icon_%d.png",i+1];
[imgView setImage:[UIImage imageNamed:imgName]];
[_scroll addSubview:imgView];
if (i == kImageCount - 1) {
// 图像和用户响应
UITapGestureRecognizer * tap =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClick)];
// [tap addTarget:self action:@selector(onClick)];
[imgView setUserInteractionEnabled:YES];
[imgView addGestureRecognizer:tap];
}
//[_scroll addSubview:imgView];
}
_scroll.contentSize = CGSizeMake(kImageCount * width, height);
_scroll.pagingEnabled = YES;
_scroll.bounces=NO;
_scroll.delegate=self;
_scroll.showsHorizontalScrollIndicator=NO;
}
-(void)onClick{
MyTabBarViewController * myTabBar =[[MyTabBarViewController alloc]init];
[self presentViewController:myTabBar animated:YES completion:^{
}];
}