一般项目中都会出现新特性页面,比如第一次使用应用的时候,或者在应用设置里查看新特性的时候会出现。

这里,选择新建一个专门处理项目新特性的控制器,来完成功能。

首先是

NewFeaturesViewController.h

#import <UIKit/UIKit.h>

typedef enum : NSInteger{
NewfeatureTypeFromeSetting, //从设置界面进入该页
NewfeatureTypeFromeWelcom, //第一次安装的时候进入
} NewFeatureType; @interface NewFeaturesViewController : UIViewController @property (nonatomic,assign) NewFeatureType newfeaturetype; @end

NewFeaturesViewController.m

#import "NewFeaturesViewController.h"
#import "ViewController.h" #define DLNewfeatureImageCount 3 @interface NewFeaturesViewController ()<UIScrollViewDelegate> @property (nonatomic,weak) UIPageControl *pageControl; @end @implementation NewFeaturesViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[UIApplication sharedApplication].statusBarHidden = YES; [self setupScrollView];
[self setupPageControl]; } -(void)setupScrollView{
//1.
UIScrollView *scrollView = [[UIScrollView alloc]init];
scrollView.frame = self.view.bounds;
scrollView.bounces = NO;
scrollView.delegate = self;
[self.view addSubview:scrollView]; //2.
CGFloat imageW = scrollView.bounds.size.width;
CGFloat imageH = scrollView.bounds.size.height;
for (int i = ; i < DLNewfeatureImageCount; i ++) {
//2.1
UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(i*imageW, , imageW, imageH)];
if (i == ) {
imgView.backgroundColor = [UIColor redColor];
}
if (i == ) {
imgView.backgroundColor = [UIColor greenColor];
}
if (i == ) {
imgView.backgroundColor = [UIColor blueColor]; [self setupLastImageView:imgView];
} [scrollView addSubview:imgView]; } scrollView.contentSize = CGSizeMake(DLNewfeatureImageCount * imageW, );
scrollView.pagingEnabled = YES; } -(void)setupPageControl{
UIPageControl *pageC = [[UIPageControl alloc]init];
pageC.center = CGPointMake(self.view.frame.size.width*0.5, self.view.frame.size.height-);
pageC.numberOfPages = DLNewfeatureImageCount;
[self.view addSubview:pageC];
self.pageControl = pageC; } -(void)setupLastImageView:(UIImageView *)imgView{
imgView.userInteractionEnabled = YES;
UIButton *startButton = [[UIButton alloc] init];
startButton.frame = CGRectMake(, imgView.frame.size.height-, imgView.frame.size.width, );
[imgView addSubview:startButton];
[startButton addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside];
[startButton setTitle:@"立即开始" forState:UIControlStateNormal];
} -(void)start{
[UIApplication sharedApplication].statusBarHidden = NO; //判断类型
if (self.newfeaturetype == NewfeatureTypeFromeWelcom) { }else{ } ViewController *vc = [[ViewController alloc]init];
//切换控制器
UIWindow *window = [UIApplication sharedApplication].keyWindow;
window.rootViewController = vc; } -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
//1.
CGFloat doublePage = scrollView.contentOffset.x / scrollView.frame.size.width;
int intpage = (int)(doublePage + 0.5);
NSLog(@"%d",intpage);
self.pageControl.currentPage = intpage;
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end

使用方法:

在AppDelegate中,将self.window.rootViewController 设置为本类,在点击“立即开始”按钮后,切换控制器为主体控制器。

iOS中的项目新特性页面的处理的更多相关文章

  1. iOS开发实用技巧—项目新特性页面的处理

    iOS开发实用技巧篇—项目新特性页面的处理 说明:本文主要说明在项目开发中会涉及到的最最简单的新特性界面(实用UIScrollView展示多张图片的轮播)的处理. 代码示例: 新建一个专门的处理新特性 ...

  2. ES6系列之项目中常用的新特性

    ES6系列之项目中常用的新特性 ES6常用特性 平时项目开发中灵活运用ES6+语法可以让开发者减少很多开发时间,提高工作效率.ES6版本提供了很多新的特性,接下来我列举项目中常用的ES6+的特性: l ...

  3. Xcode中StoryBoard Reference 新特性的使用

    html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...

  4. MVC中的其他新特性

    MVC中的其他新特性 (GlobalImport全局导入功能) 默认新建立的MVC程序中,在Views目录下,新增加了一个_GlobalImport.cshtml文件和_ViewStart.cshtm ...

  5. ios学习路线—Objective-C(新特性)

    1.方法顺序无关 Objective-C类由声明文件h和实现文件m组成,所有的public方法都在h文件中声明,private方法可以写在m文件中,但是在早期的编译环境中需要注意方法的顺序,例如下面的 ...

  6. Jdk5.0中出现的新特性

    掌握jdk5.0中出现的新特性1.泛型(Generics)2.增强的"for"循环(Enhanced For loop)3.自动装箱/自动拆箱(Autoboxing/unboxin ...

  7. C#6.0 中的那些新特性

    C#6.0 中的那些新特性 前言 VS2015在自己机器上确实是装好了,费了老劲了,想来体验一下跨平台的快感,结果被微软狠狠的来了一棒子了,装好了还是没什么用,应该还需要装Xarmain插件,配置一些 ...

  8. 浅析Oracle 12c中Data Guard新特性

    浅析Oracle 12c中Data Guard新特性   写在前面 无论是做Oracle运维的小伙伴还是老伙伴,想必对Oracle数据库的数据级灾备核心技术—Data Guard是再熟悉不过了!这项从 ...

  9. Ionic3新特性--页面懒加载1

    Ionic3新的懒加载机制给我带来了如下新特性: 避免在每一个使用到某Page的Module或其他Page中重复的import这个类(需要写一堆路径) 允许我们通过字符串key在任何想使用的地方获取某 ...

随机推荐

  1. JavaScript忍者秘籍——原型

    概要:本篇博客主要介绍JavaScript的原型 1.对象实例化 - 初始化的优先级 初始化操作的优先级如下: ● 通过原型给对象实例添加的属性 ● 在构造器函数内给对象实例添加的属性 在构造器内的绑 ...

  2. 《Intel汇编第5版》 条件汇编伪指令

    一.条件汇编伪指令和宏使用可以使汇编程序更加灵活 二.通过伪指令来检查函数的参数是否为空,如果为空则输出警告信息 INCLUDE Irvine32.inc includelib Irvine32.li ...

  3. Python的加入!

    今天有幸领略了Python的风采. 真是好清新>_< 赶紧尝试一下. 好酷. 以后会在项目中使用

  4. Wise Registry Cleaner Pro(智能注册表清理) V9.31 绿色版

    软件名称: Wise Registry Cleaner Pro(智能注册表清理)软件语言: 简体中文授权方式: 免费试用运行环境: Win7 / Vista / Win2003 / WinXP 软件大 ...

  5. Mac下Cordova开发环境搭建

    xcode下载 从Mac App Store 下载Xcode,只需要在Store键入Xcode,下载第一个就ok了 cordova安装与配置 cordova需要node安装,使用Safari打开nod ...

  6. ntp升级

    1. 系统与软件版本 1.1 系统版本 CentOS6.5 x86_64 1.2 ntpd软件版本 ntp-4.2.8p9.tar.gz 1.3 下载地址 官方下载地址:http://support. ...

  7. [译][待续]Chap1.Using neural nets to recognize handwritten digits

    Chapter1 使用神经网络辨识手写数字 人类的视觉系统是自然界的一大奇迹.试看如下的手写数列: 绝大多数人都能毫不费劲地认出这些数字是504192,而这会让人产生识别数字非常简单的错觉.人类大脑的 ...

  8. python demo整理

    1 变量作用域 #!/usr/bin/python # coding=utf-8 name = "whole global name" class Person: name = & ...

  9. date,datetime,timestamp 的区别

    date 表示年月日,如YY-MM-DD datetime 表示年月日和时间信息,如YY-MM-DD HH:MM:SS datestamp 和datetime表示的信息相同,但时间范围不同 时间范围 ...

  10. python获取

    def anc():pass print anc.__name__ def timeit(func): def run(*argv): print "this function name i ...