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在任何想使用的地方获取某 ...
随机推荐
- Java:注解(Annotation)自定义注解入门
转载地址:http://www.cnblogs.com/peida/archive/2013/04/24/3036689.html 要深入学习注解,我们就必须能定义自己的注解,并使用注解,在定义自己的 ...
- 用 monitorix 开启linux图形化监控
# yum install monitorix # service monitorix starthttp://host:8080/monitorix/
- PHP22期基础班技术总结
- python 内嵌函数, 闭包, 函数装饰器
一. 函数内嵌 闭包 在python中,函数可以作为返回值, 可以给变量赋值. 在python中, 内置函数必须被显示的调用, 否则不会执行. #!/usr/bin/env python #-*- ...
- AppDelegate 里一个基本的跳转方法,用来在rootView崩溃的时候直接调试我自己的页面
将 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)lau ...
- Jenkins2.32.1+svn+maven安装配置与构建部署
这两天学习了一下持久化集成工具Jenkins,在自己的本地搭建一个简单的Jenkins环境. 使用环境:Windows64系统,JDK1.8,eclipse,svn(Windows版本VisualSV ...
- iOS 导航栏 不透明
UINavigationBar.appearance().translucent = false UINavigationBar.appearance().barStyle = UIBarStyle. ...
- libev中timer时间事件监控器
1.数据结构 #define ev_at(w) ((WT)(w))->at#define ev_active(w) ((W)(w))->active typedef ev_watcher_ ...
- java设计模式(三)
单例模式在一个jvm中有且仅有一个对象(1)内部静态类实现 class Singleton{ /*构造方法私有 防止实例化*/ private Singleton(){}; public static ...
- Ubuntu下安装composer及配置
1.下载最新composer wget -c https://getcomposer.org/composer.phar 2.可执行权限 chmod u+x composer.phar 3.放置到安装 ...