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

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

首先是

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. [Q]关于无法进入主界面问题解答

    打图精灵适用于AutoCAD2007或更高版,低于2007版无法使用. 若在安装打图精灵前AutoCAD已经打开,则需要将AutoCAD重新打开,然后使用“QPlot”命令. 若重新打开仍然调不出界面 ...

  2. C# 语言规范_版本5.0 (第14章 枚举)

    1. 枚举 枚举类型 (enum type) 是一种独特的值类型(第 4.1 节),它用于声明一组命名的常量. 下面的示例 enum Color { Red, Green, Blue } 声明一个名为 ...

  3. ios 开发证书 appids 描述文件关系

    当你准备进行真机测试或者发布应用到App Store上去的时候, 免不了要申请相应的证书.(Development--测试证书. Distribution--发布证书) 进入证书管理相应网站https ...

  4. chrome手动添加拓展

    https://www.crx4chrome.com/crx/978/ Free Download Postman REST Client CRX 0.8.4.19 for ------------- ...

  5. Quartz的cron表达式

    一个cron表达式有至少6个(也可能7个)有空格分隔的时间元素. 按顺序依次为 秒(0~59) 分钟(0~59) 小时(0~23) 天(月)(0~31,但是你需要考虑你月的天数) 月(0~11) 天( ...

  6. 用VB把xlsx转换为xls

    Sub Test()Dim wb As Workbook, mPath As String, f As StringApplication.DisplayAlerts = FalseApplicati ...

  7. IIS下访问网络驱动器(网络位置)

    System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd.ex ...

  8. openstack私有云布署实践【7.2 keystone + memcache (办公网环境)】

    首先登录controller1创建keystone数据库,并赋于远程和本地访问的权限.   mysql -u root -p CREATE DATABASE keystone; GRANT ALL P ...

  9. Linux用户相关命令

    1.建用户: adduser snailz //新建用户 snailz passwd snailz //给用户 snailz 设置密码 2.建工作组 groupadd test //新建test工作组 ...

  10. 关于css3中transform的理解(只是改变状态未改变其真正的属性)

    众所周知,在css3中可以用animation实现动画效果,在这里用一个transform:translateX举例. <div class="div1"></d ...