A.版本新特性
1.需求
  • 第一次使用新版本的时候,不直接进入app,而是展示新特性界面
 
 
 
2.思路
  • [[NSBundle mainBundle] infoDictionary]取得当前版本号(最新版本),版本号存储在了info.plist中
  • 从preference取得上一次使用的版本号
  • 将讲个版本号进行对比,如果相同就是当前是最新版本,直接进入app;如果不相同,就进入新特性界面并保存最新版本号到preference
 
当前版本号:
 
当前版本号的key
 
 
3.实现
(1)创建一个新的目录来处理新特性加载
 
自定义一个集成UIViewController的类来处理新特性界面
(注意scrollView没有相应控制器,只能在其他view上加载)
 
 
(2)在AppDelegate中app加载完毕方法中
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch. // 启动后显示状态栏
UIApplication *app = [UIApplication sharedApplication];
app.statusBarHidden = NO; // 设置window
self.window = [[UIWindow alloc] init];
self.window.frame = [UIScreen mainScreen].bounds; /** 新版本特性 */
// app现在的版本
// 由于使用的时Core Foundation的东西,需要桥接
NSString *versionKey = (__bridge NSString*) kCFBundleVersionKey;
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *currentVersion = [infoDic objectForKey:versionKey]; // 上次使用的版本
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *lastVersion = [defaults stringForKey:versionKey]; // 如果版本变动了,存储新的版本号并启动新版本特性图
if (![lastVersion isEqualToString:currentVersion]) { // 存储
[defaults setObject:currentVersion forKey:versionKey];
[defaults synchronize]; // 开启app显示新特性
HVWNewFeatureViewController *newFeatureVC = [[HVWNewFeatureViewController alloc] init];
self.window.rootViewController = newFeatureVC;
} else {
// 创建根控制器
HVWTabBarViewController *tabVC = [[HVWTabBarViewController alloc] init];
self.window.rootViewController = tabVC;
} [self.window makeKeyAndVisible]; return YES;
}
 
 
 
B.版本新特性的内容
1.需求
  • 在特特性界面使用轮播方式显示若干个界面
  • 最后一个界面提供一个分享功能和进入app功能
 
2.思路
  • 在新特性控制器的view上加入一个全屏的scrollView
 
3.实现
 //
// HVWNewFeatureViewController.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/3.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWNewFeatureViewController.h"
#import "HVWTabBarViewController.h" #define NewFeatureCount 4 @interface HVWNewFeatureViewController () <UIScrollViewDelegate> @property(nonatomic, strong) UIPageControl *pageControl; @end @implementation HVWNewFeatureViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. // 添加scrollView
[self setupScrollView]; // 添加pageControl
[self setupPageControl];
} /** 添加scrollView */
- (void) setupScrollView {
// 创建一个scrollView
UIScrollView *scrollView = [[UIScrollView alloc] init];
scrollView.frame = self.view.bounds; // 添加图片
for (int i=; i<NewFeatureCount; i++) { // 获取图片
NSString *featureImageName = [NSString stringWithFormat:@"new_feature_%d", i+];
UIImageView *featureImageView = [[UIImageView alloc] initWithImage:[UIImage imageWithNamed:featureImageName]]; // 设置图片尺寸位置
CGFloat featureWidth = self.view.width;
CGFloat featureHeight = self.view.height;
CGFloat featureX = featureImageView.width * i;
CGFloat featureY = ;
featureImageView.frame = CGRectMake(featureX, featureY, featureWidth, featureHeight); // 如果是最后一页,加上功能按钮
if (i == (NewFeatureCount - )) {
// 为了让最后一页的的功能按钮能够生效,必须激活交互功能
featureImageView.userInteractionEnabled = YES; [self addFunctionButton:featureImageView];
} // 添加图片到scrollView
[scrollView addSubview:featureImageView];
} // 设置scrollView功能属性
scrollView.userInteractionEnabled = YES;
scrollView.scrollEnabled = YES; // 支持滚动
scrollView.contentSize = CGSizeMake(self.view.width * NewFeatureCount, ); // 只需要水平滚动
scrollView.pagingEnabled = YES; // 支持分页
scrollView.showsHorizontalScrollIndicator = NO; // 隐藏水平滚动条 // 设置背景色
scrollView.backgroundColor = [UIColor colorWithRed:/255.0 green:/255.0 blue:/255.0 alpha:1.0]; // 设置代理
scrollView.delegate = self; // 添加
[self.view addSubview:scrollView];
} /** 添加pageControl */
- (void) setupPageControl {
// pageControl不能加在scrollView上,不然会随着内容一起滚动
UIPageControl *pageControl = [[UIPageControl alloc] init];
pageControl.pageIndicatorTintColor = [UIColor blackColor];
pageControl.currentPageIndicatorTintColor = [UIColor redColor];
pageControl.numberOfPages = NewFeatureCount; // 设置位置
pageControl.centerX = self.view.width * 0.5;
pageControl.centerY = self.view.height * 0.9; self.pageControl = pageControl;
[self.view addSubview:pageControl];
} #pragma mark - UIScrollViewDelegate
/** scrollView滚动代理方法,在这里控制页码指示器 */
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
// 四舍五入,让图片滚动超过中线的时候改变页码
self.pageControl.currentPage = scrollView.contentOffset.x / scrollView.width + 0.5;
} #pragma mark - 最后一页的功能
/** 添加功能按钮 */
- (void) addFunctionButton:(UIImageView *) imageView {
// 添加"分享"选项按钮
[self addShareButton:imageView]; // 添加"进入微博"按钮
[self addEnterWeiboButton:imageView];
} /** 分享选项按钮 */
- (void) addShareButton:(UIImageView *) imageView {
// 创建按钮
UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom]; [shareButton setTitle:@"分享给大家" forState:UIControlStateNormal]; [shareButton setImage:[UIImage imageWithNamed:@"new_feature_share_false"] forState:UIControlStateNormal];
[shareButton setImage:[UIImage imageWithNamed:@"new_feature_share_true"] forState:UIControlStateSelected]; [shareButton addTarget:self action:@selector(shareButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; [shareButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; // 位置尺寸
shareButton.size = CGSizeMake(, ); // 必须先设置了size,center才真的在中心,不然就是从左上角开始!!!
shareButton.centerX = self.view.width * 0.5;
shareButton.centerY = self.view.height * 0.65; // 设置内间距
shareButton.titleEdgeInsets = UIEdgeInsetsMake(, 10.0, , ); // 添加
[imageView addSubview:shareButton];
} /** 分享选项点击事件方法 */
- (void) shareButtonClicked:(UIButton *) button {
button.selected = !button.selected;
} /** “进入微博"按钮 */
- (void) addEnterWeiboButton:(UIImageView *) imageView {
// 创建按钮
UIButton *enterButton = [UIButton buttonWithType:UIButtonTypeCustom];
enterButton.userInteractionEnabled = YES;
[enterButton setBackgroundImage:[UIImage imageWithNamed:@"new_feature_finish_button"] forState:UIControlStateNormal];
[enterButton setBackgroundImage:[UIImage imageWithNamed:@"new_feature_finish_button_highlighted"] forState:UIControlStateHighlighted];
[enterButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[enterButton setTitle:@"进入微博" forState:UIControlStateNormal]; // 位置尺寸
enterButton.size = enterButton.currentBackgroundImage.size;
enterButton.centerX = self.view.width * 0.5;
enterButton.centerY = self.view.height * 0.8; // 监听点击
[enterButton addTarget:self action:@selector(enterWeiboButtonClicked) forControlEvents:UIControlEventTouchUpInside]; // 添加
[imageView addSubview:enterButton];
} /** “进入微博” 按钮点击 */
- (void) enterWeiboButtonClicked {
UIWindow *window = [UIApplication sharedApplication].keyWindow;
window.rootViewController = [[HVWTabBarViewController alloc] init];
} @end
 
 

[iOS微博项目 - 1.7] - 版本新特性的更多相关文章

  1. IOS第三天-新浪微博 - 版本新特性,OAuth授权认证

    *********版本新特性 #import "HWNewfeatureViewController.h" #import "HWTabBarViewController ...

  2. [iOS微博项目 - 2.1] - 获得新浪授权接口

    A.如何获得新浪的授权接口 登陆新浪的开放平台 注册新浪账号 创建应用 获得应用id和请求地址 查阅相关API 关联需要进行测试的账号   1.登陆开放平台 http://open.weibo.com ...

  3. IOS 制作版本新特性

    创建版本新特性 页面(存放图片) HMNewfeatureViewController.m #define HMNewfeatureImageCount 4 #import "HMNewfe ...

  4. Atitit opencv版本新特性attilax总结

    Atitit opencv版本新特性attilax总结 1.1. :OpenCV 3.0 发布,史上功能最全,速度最快的版1 1.2. 应用领域2 1.3. OPENCV2.4.3改进 2.4.2就有 ...

  5. Atitit mac os 版本 新特性 attilax大总结

    Atitit mac os 版本 新特性 attilax大总结 1. Macos概述1 2. 早期2 2.1. Macintosh OS (系统 1.0)  1984年2 2.2. Mac OS 7. ...

  6. 【开源】OSharp3.3框架解说系列:重新开源及3.3版本新特性

    OSharp是什么? OSharp是个快速开发框架,但不是一个大而全的包罗万象的框架,严格的说,OSharp中什么都没有实现.与其他大而全的框架最大的不同点,就是OSharp只做抽象封装,不做实现.依 ...

  7. framework各版本新特性(为面试准备)

    菜鸟D估计描述这些新特性的文章都是烂大街的货色,之所以拿出来分(e)享(xin)一下,有两个原因:1.当年面试的时候有人问到,我不知道该怎么回答:2.项目需要发布了,但是考虑到framework的版本 ...

  8. Atitit.jquery 版本新特性attilax总结

    Atitit.jquery 版本新特性attilax总结 1. Jq1.4 1 2. 1.5 1 3. 1.6 3 4. Jq1.7 3 ⒉提升了事件委派时的性能有了大幅度的提升,尤其是在ie7下: ...

  9. Atitit..jdk java 各版本新特性 1.0 1.1 1.2 1.3 1.4 1.5(5.0) 1.6(6.0) 7.0 8.0 9.0 attilax 大总结

    Atitit..jdk java 各版本新特性 1.0 1.1 1.2 1.3 1.4 1.5(5.0) 1.6(6.0) 7.0 8.0 9.0 attilax 大总结 1.1. Java的编年史2 ...

随机推荐

  1. Codeforces Beta Round #2B(dp+数学)

    贡献了一列WA.. 数学很神奇啊 这个题的关键是怎么才能算尾0的个数 只能相乘 可以想一下所有一位数相乘 除0之外,只有2和5相乘才能得到0 当然那些本身带0的多位数 里面肯定含有多少尾0 就含有多少 ...

  2. Android中ProgressDialog的简单示例

    网上一般对进度条的示例都是如何显示,没有在任务结束如何关闭的文章,参考其他文章经过试验之后把整套进度条显示的简单示例如下: 建立android工程等工作都略去,Google一下就可以了. 下面来介绍主 ...

  3. Python3 学习第一弹:基本数据类型

    本人学习主要从<python基础教程第二版>,<dive into python3>等书籍,及一些网上大牛的博客中学习特别是Python官方文档<Python Tutor ...

  4. Codeforces 383A - Milking cows

    原题地址:http://codeforces.com/problemset/problem/383/A 题目大意:有 n 头奶牛,全部看着左边或者右边,现在开始给奶牛挤奶,给一头奶牛挤奶时,所有能看到 ...

  5. 获取本机外网ip和内网ip

    获取本机外网ip //获取本机的公网IP public static string GetIP() { string tempip = ""; try { WebRequest r ...

  6. Ajax、Comet与Websocket

    从 http 协议说起 1996年IETF  HTTP工作组发布了HTTP协议的1.0版本 ,到现在普遍使用的版本1.1,HTTP协议经历了17 年的发展.这种分布式.无状态.基于TCP的请求/响应式 ...

  7. listview默认选择第一项,点击换子项背景图

    (不是大神,没有几百子项目,去你丫的) private int last_item_position ; @Override public void onItemClick(AdapterView&l ...

  8. HelloX操作系统与中国移动OneNET物联网平台成功完成对接

    HelloX成功与中国移动物联网平台对接 经过HelloX项目组同仁的努力,尤其是Tywin(@飓风)的努力下,HelloX最新版本V1.78已成功与中国移动OneNET(open.iot.10086 ...

  9. 【C#学习笔记】类型转换

    using System; namespace ConsoleApplication { class Program { static void Main(string[] args) { " ...

  10. ActionBarSherlock的学习笔记(四) ------------ ActionBarSherlock中的搜索及SearchView的使用

    在使用ActionBarSherlock定义app的头部操作时,会经常看见搜索的动作,本文主要介绍一下搜索是如何实现的. 1. SearchView 是搜索的核心组件,具体介绍请参考Android官方 ...