iOS中的项目新特性页面的处理
一般项目中都会出现新特性页面,比如第一次使用应用的时候,或者在应用设置里查看新特性的时候会出现。
这里,选择新建一个专门处理项目新特性的控制器,来完成功能。
首先是
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中的项目新特性页面的处理的更多相关文章
- iOS开发实用技巧—项目新特性页面的处理
iOS开发实用技巧篇—项目新特性页面的处理 说明:本文主要说明在项目开发中会涉及到的最最简单的新特性界面(实用UIScrollView展示多张图片的轮播)的处理. 代码示例: 新建一个专门的处理新特性 ...
- ES6系列之项目中常用的新特性
ES6系列之项目中常用的新特性 ES6常用特性 平时项目开发中灵活运用ES6+语法可以让开发者减少很多开发时间,提高工作效率.ES6版本提供了很多新的特性,接下来我列举项目中常用的ES6+的特性: l ...
- Xcode中StoryBoard Reference 新特性的使用
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...
- MVC中的其他新特性
MVC中的其他新特性 (GlobalImport全局导入功能) 默认新建立的MVC程序中,在Views目录下,新增加了一个_GlobalImport.cshtml文件和_ViewStart.cshtm ...
- ios学习路线—Objective-C(新特性)
1.方法顺序无关 Objective-C类由声明文件h和实现文件m组成,所有的public方法都在h文件中声明,private方法可以写在m文件中,但是在早期的编译环境中需要注意方法的顺序,例如下面的 ...
- Jdk5.0中出现的新特性
掌握jdk5.0中出现的新特性1.泛型(Generics)2.增强的"for"循环(Enhanced For loop)3.自动装箱/自动拆箱(Autoboxing/unboxin ...
- C#6.0 中的那些新特性
C#6.0 中的那些新特性 前言 VS2015在自己机器上确实是装好了,费了老劲了,想来体验一下跨平台的快感,结果被微软狠狠的来了一棒子了,装好了还是没什么用,应该还需要装Xarmain插件,配置一些 ...
- 浅析Oracle 12c中Data Guard新特性
浅析Oracle 12c中Data Guard新特性 写在前面 无论是做Oracle运维的小伙伴还是老伙伴,想必对Oracle数据库的数据级灾备核心技术—Data Guard是再熟悉不过了!这项从 ...
- Ionic3新特性--页面懒加载1
Ionic3新的懒加载机制给我带来了如下新特性: 避免在每一个使用到某Page的Module或其他Page中重复的import这个类(需要写一堆路径) 允许我们通过字符串key在任何想使用的地方获取某 ...
随机推荐
- [SOJ] shortest path in unweighted graph
Description 输入一个无向图,指定一个顶点s开始bfs遍历,求出s到图中每个点的最短距离. 如果不存在s到t的路径,则记s到t的距离为-1. Input 输入的第一行包含两个整数n和m, ...
- Struts2的通配符配置方式
Struts2的Action类很有意思,你可以使用3种方式来实现具体的Action类: 让你的Action类继承自ActionSupport类(项目中最常用这种方式,因为ActionSupport类中 ...
- ASP.NET Calendar(日历控件)
定义和用法 Calendar 控件用于在浏览器中显示日历. 该控件可显示某个月的日历,允许用户选择日期,也可以跳到前一个或下一个月. 属性 属性 描述 .NET Caption 日历的标题. 2.0 ...
- C++类与static
到目前为止,我们设计的类中所有的成员变量和成员函数都是属于对象的,如我们在前面定义的book类,利用book类声明两个对象Alice和Harry,这两个对象均拥有各自的price和title成员变量, ...
- OOP的方法
<?php class Computer{ //我要创建一个构造方法 public function __construct(){ echo '我是比较先进的构造方法!'; //构造方法一般用于 ...
- IIS优化服务器性能导致QuartZ任务未运行
问题: IIS 为优化服务器性能,会自动对它认为休眠的应用程序进行资源回收,资源回收将会导致网站应用程序关闭. 解决方案: 1. 设置闲置超时为0,固定回收时间间隔为0,即IIS不主动回收闲置进程 ...
- asp.net 后台验证成功(弹出对话框)并跳转?不能实现
原始 Context.Response.Write("<script></script>"); Response.Redirect(); 解决办法: Cli ...
- python变量与数据类型
变量 什么是变量 所谓变量,指的是在程序运行过程中需要用到的中间结果,变量定义后,会占用一块内存开辟的空间地址,通过内存空间确保同一时间的唯一性. >>> print(id.__do ...
- Android app作为系统应用实现功能笔记
1.禁用StatusBar相关功能需要添加权限 <uses-permission android:name="android.permission.STATUS_BAR"&g ...
- System.Diagnostics.Process 执行.EXE
分类: C#+WINFORM 2009-04-05 21:09 459人阅读 评论(0) 收藏 举报 我们经常会遇到在Winform或是WPF中点击链接或按钮打开某个指定的网址, 或者是需要打 ...