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

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

首先是

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. CentOS 7将Python 2.X.X升级到Python 3.X.X

    # cd /usr/local/src/ # ls Python-.tgz # .tgz # ls Python- Python-.tgz # cd Python-/ # yum install gc ...

  2. HTML5历史管理

    边看视频边做的练习,随机显示数字,分别使用history和hash来实现历史管理 <!doctype html> <html> <head> <meta ch ...

  3. ABAP字符串操作 截取字符长度 取位数

    ABAP字符串操作   ABAP對字串的操作方法與其他語言的操作有較大差別,以下是較常用的對字串操作的方法: 1. 字串的連接:CONCATENATEDATA: t1 TYPE c LENGTH 10 ...

  4. ccf cv讲座记录

  5. Vladik and cards

    Vladik and cards time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  6. 微信支付服务商模式(受理机构模式)开发注意事项,jsapi支付

    1.首先下载的demo,一般都是有些bug的,先要改一下. 2.微信貌似没有为服务商模式单独开发demo,下载的也都是普通商户的支付demo,其实这里没有必要单独写,因为他们区别就是几个参数的区别. ...

  7. JavaScript 执行环境(执行上下文) 变量对象 作用域链 上下文 块级作用域 私有变量和特权方法

    总结自<高程三>第四章  理解Javascript_12_执行模型浅析   JS的执行环境与作用域  javascript高级程序第三版学习笔记[执行环境.作用域] 在javascript ...

  8. jquery 学习笔记 (2)--write less,do more

    $(window).load(function(){      })           window.onload=function(){ } toggle()方法 toggle()方法的语法结构: ...

  9. 在hadoop 的任务中设置 map数量

    试验了一下: 调整mapred-site.xml中mapred.min.split.size的值可以改变map的数量 首先设置了hdfs-site.xml中的dfs.block.size为20M,测试 ...

  10. Xcode-之CocoaPads

    一.说明 CocoaPods是OS X和iOS下的一个第三类库管理工具,通过CocoaPods工具我们可以为项目添加被称为“Pods”的依赖库(这些类库必须是CocoaPods本身所支持的),并且可以 ...