if(![[NSUserDefaults standardUserDefaults] boolForKey:@"firstStart"]){
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstStart"];
NSLog(@"第一次启动");
}else{
NSLog(@"不是第一次启动");
}
+ (NSString *)appVersion
{
NSString *versionValue = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
return versionValue;
}
- Info.plis→Bundle version当前版本号
-
[NSBundle mainBundle].infoDictionary
- 版本号和沙盒里存储不一致时,新版本
- 把软件卸载
- 修改plist版本号
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreenmainScreen] bounds]];
// 取出沙盒中上一次使用软件的版本号
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *lastVersion = [defaults stringForKey:@"lastVersion"];
// 获得当前软件的版本号
NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
if ([currentVersion isEqualToString:lastVersion]) {
// 显示状态栏
application.statusBarHidden = NO;
self.window.rootViewController = [[MgTabBarViewController alloc] init];
} else { // 新版本
self.window.rootViewController = [[MGNewfeatureViewController alloc] init];
// 存储新版本
[defaults setObject:currentVersion forKey:@"lastVersion"];
}
[self.window makeKeyAndVisible];
return YES;
}
@interface MGNewfeatureViewController() <UIScrollViewDelegate>
@property (nonatomic, weak) UIPageControl *pageControl;
@end
#pragma mark scrollView的控制器
/**
* 只要UIScrollView滚动了,就自动调用
*/
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// 1.取出水平方向上滚动的距离
double offsetX = scrollView.contentOffset.x;
// 2.求出页码
double pageDouble = offsetX / scrollView.frame.size.width;
// 谁占主动,就显示谁
int pageInt = (int)(pageDouble + 0.5);
// MGLog(@"------%f-----%d", pageDouble, pageInt);
self.pageControl.currentPage = pageInt;
}
网友评论