APP新启动的时候,都会有几张新的图片滑动,才能到主的界面。现在,我们新建一个控制器,专门来处理新特性,直接上代码.

第一步:新建一个NewfeatureController

//
// HWNewfeatureController.m
// Weibo
//
// Created by jys on 15/3/24.
// Copyright (c) 2015年 weibo. All rights reserved.
// #import "HWNewfeatureController.h"
#import "HWTabBarViewController.h" #define HWNewfeatureCount 4 @interface HWNewfeatureController ()<UIScrollViewDelegate> @property (nonatomic,weak) UIPageControl *pageControl;
@property (nonatomic,weak) UIScrollView *scrollView; @end @implementation HWNewfeatureController - (void)viewDidLoad {
[super viewDidLoad];
//1.创建一个scrollView,显示所有的新特性图片
UIScrollView *scrollView=[[UIScrollView alloc] init];
scrollView.frame=self.view.bounds;
[self.view addSubview:scrollView];
self.scrollView=scrollView; //2.添加图片到scrollView中
CGFloat scrollW=scrollView.width;
CGFloat scrollH=scrollView.height; for (int i=; i<HWNewfeatureCount; i++) {
UIImageView *imageView=[[UIImageView alloc] init];
imageView.width=scrollW;
imageView.height=scrollH;
imageView.y=;
imageView.x=i*scrollW; //显示图片
NSString *name = [NSString stringWithFormat:@"new_feature_%d", i + ];
imageView.image=[UIImage imageNamed:name];
[scrollView addSubview:imageView]; // 如果是最后一个imageView,就往里面添加其他内容
if (i == HWNewfeatureCount - ) {
[self setupLastImageView:imageView];
}
} //3.设置scrollView的其它属性
//如果想要某个方向上不能滚动,那么这个方向对应的尺寸数值传0即可
scrollView.contentSize=CGSizeMake(scrollView.width*HWNewfeatureCount, );
scrollView.bounces=NO;//去除弹簧效应
scrollView.pagingEnabled=YES;//分页,一张一张的滚动
scrollView.showsHorizontalScrollIndicator=NO;//没有滚动条
scrollView.delegate = self; //4.添加pageController分页,展示目前看的是第几页
UIPageControl *pageControl=[[UIPageControl alloc] init];
pageControl.numberOfPages=HWNewfeatureCount;
pageControl.backgroundColor=[UIColor redColor];
pageControl.currentPageIndicatorTintColor=HWColor(, , );
pageControl.pageIndicatorTintColor=HWColor(, , );
pageControl.centerX=scrollW*0.5;
pageControl.centerY=scrollH-;
[self.view addSubview:pageControl];
self.pageControl=pageControl; // UIPageControl就算没有设置尺寸,里面的内容还是照常显示的,该控件相对特别
// pageControl.width = 100;
// pageControl.height = 50;
// pageControl.userInteractionEnabled = NO;
} //当前页面滚到哪页
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
double page=scrollView.contentOffset.x/scrollView.width;
self.pageControl.currentPage=(int)(page+0.5);
} /**
* 初始化最后一个imageView
*
* @param imageView <#imageView description#>
*/
-(void)setupLastImageView:(UIImageView *)imageView
{
//开启交互功能
imageView.userInteractionEnabled=YES; //1.分享给大家
UIButton *shareBtn=[[UIButton alloc]init];
[shareBtn setImage:[UIImage imageNamed:@"new_feature_share_false"] forState:UIControlStateNormal];
[shareBtn setImage:[UIImage imageNamed:@"new_feature_share_true"] forState:UIControlStateSelected]; [shareBtn setTitle:@"分享给大家" forState:UIControlStateNormal];
[shareBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
shareBtn.titleLabel.font=[UIFont systemFontOfSize:];
shareBtn.width=;
shareBtn.height=;
shareBtn.centerX=imageView.width*0.5;
shareBtn.centerY=imageView.height*0.65;
// top left bottom right
shareBtn.titleEdgeInsets = UIEdgeInsetsMake(, , , );
[shareBtn addTarget:self action:@selector(shareClick:) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:shareBtn]; //2.开始微博
UIButton *startBtn=[[UIButton alloc] init];
[startBtn setBackgroundImage:[UIImage imageNamed:@"new_feature_finish_button"] forState:UIControlStateNormal];
[startBtn setBackgroundImage:[UIImage imageNamed:@"new_feature_finish_button_highlighted"] forState:UIControlStateHighlighted];
startBtn.size=startBtn.currentBackgroundImage.size;
startBtn.centerX=imageView.width*0.5;
startBtn.centerY=imageView.height*0.75;
[startBtn setTitle:@"开始微博" forState:UIControlStateNormal];
[startBtn addTarget:self action:@selector(startClick) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:startBtn];
//startBtn.centerX=imageView } -(void)shareClick:(UIButton *)shareBtn
{
//状态取反
shareBtn.selected=!shareBtn.isSelected;
} //开始微博
-(void)startClick
{
UIWindow *window=[UIApplication sharedApplication].keyWindow;
window.rootViewController=[[HWTabBarViewController alloc]init]; } @end

上面的代码中,需要注意的是:

开始微博,显示主界面时,请使用rootViewController来处理,如果用其它方式,新特性界面并没有销毁,留下隐患。

- (void)startClick
{
// 切换到HWTabBarController
/*
切换控制器的手段
1.push:依赖于UINavigationController,控制器的切换是可逆的,比如A切换到B,B又可以回到A
2.modal:控制器的切换是可逆的,比如A切换到B,B又可以回到A
3.切换window的rootViewController
*/
UIWindow *window = [UIApplication sharedApplication].keyWindow;
window.rootViewController = [[HWTabBarViewController alloc] init]; // modal方式,不建议采取:新特性控制器不会销毁
// HWTabBarViewController *main = [[HWTabBarViewController alloc] init];
// [self presentViewController:main animated:YES completion:nil];
}

第二步,程序启动时,判断版本号。如果版本号不一致,则显示新特性。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// 1.创建窗口
self.window = [[UIWindow alloc] init];
self.window.frame = [UIScreen mainScreen].bounds; // 2.设置根控制器
NSString *key = @"CFBundleVersion";
// 上一次的使用版本(存储在沙盒中的版本号)
NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:key];
// 当前软件的版本号(从Info.plist中获得)
NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key]; if ([currentVersion isEqualToString:lastVersion]) { // 版本号相同:这次打开和上次打开的是同一个版本
self.window.rootViewController = [[HWTabBarViewController alloc] init];
} else { // 这次打开的版本和上一次不一样,显示新特性
self.window.rootViewController = [[HWNewfeatureViewController alloc] init]; // 将当前的版本号存进沙盒
[[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
[[NSUserDefaults standardUserDefaults] synchronize];
} // 3.显示窗口
[self.window makeKeyAndVisible];
return YES;
}

iOS 界面启动时,功能新特征显示的更多相关文章

  1. 换了XCode版本之后,iOS应用启动时不占满全屏,上下有黑边

    原因是没有Retina4对应的启动图片,解决方法很简单,就是把Retina4对应的图片给补上就只可以了

  2. 关于GOM引擎启动时显示:windows socket error: 在其上下文中,该请求的地址无效。 (10049), on API 'bind'

    GOM启动时网管登陆器显示:windows socket error: 在其上下文中,该请求的地址无效. (10049), on API 'bind'解决方法: 重新配置引擎控制台.在配置里取消双IP ...

  3. 解决VirtualBox 上的XP 关机时重启 , 启动时蓝屏 ,点击电源选项蓝屏

    三个问题一次性解决. 启动时的蓝屏显示错误信息是: STOP 0x000000CE (...) DRIVER_UNLOADED_WITHOUT_CANCELLING_PENDING_OPERATION ...

  4. Ubuntu 14.04默认以字符界面启动

    在windows上跑虚拟机比较资源,特别当以图形界面启动时,如果宿主机性能不好,就相当卡. 让Ubuntu 14.04默认以字符界面启动的方法: 编辑文件:etc/default/grub 将  GR ...

  5. iOS启动图launchImage设置后在启动时无法显示

    iOS设置启动图: 会发现运行APP不显示设置好的启动图 解决方法: 卸载之前运行的APP,检查以下配置,将LaunchScreen删除即可. 原因: launchImage 是在没有LaunchSc ...

  6. ios新特征 ARC详解

    IOS ARC 分类: IOS ARC2013-01-17 09:16 2069人阅读 评论(0) 收藏 举报   目录(?)[+]   关闭工程的ARC(Automatic Reference Co ...

  7. 【iOS翻译】App启动时的响应过程

    Responding to the Launch of Your App Initialize your app’s data structures, prepare your app to run, ...

  8. iOS 14.5 有啥新功能?Apple Watch 也能解锁 iPhone 了

    转: iOS 14.5 有啥新功能?Apple Watch 也能解锁 iPhone 了 苹果今天发布了即将发布的 iOS 14.5 和 iPadOS 14.5 更新的第一个 Beta 版本,我们在其中 ...

  9. 探秘IntelliJ IDEA 13测试版新功能——调试器显示本地变量

    IntelliJ IDEA在业界被公认为最好的Java开发平台之一,JetBrains公司将在12月正式发布IntelliJ IDEA 13版本. 现在,小编将和大家一起探秘密IntelliJ IDE ...

随机推荐

  1. SharpGL学习笔记(三) 投影变换和视点变换

    从本节开始,我们使用SharpGL带的VS2010扩展,来直接生成SharpGL工程. 如果你新建项目时,没有看到下面的SharpGL项目,那么请事先在SharpGL源代码中找到一个叫 ”SharpG ...

  2. Elasticsearch学习之深入聚合分析一---基本概念

    首先明白两个核心概念:bucket和metric 1. bucket:一个数据分组 city name 北京 小李 北京 小王 上海 小张 上海 小丽 上海 小陈 基于city划分buckets,划分 ...

  3. 【BZOJ5090】组题 分数规划

    [BZOJ5090]组题 Description 著名出题人小Q的备忘录上共有n道可以出的题目,按照顺序依次编号为1到n,其中第i道题目的难度系数被小Q估计为a_i,难度系数越高,题目越难,负数表示这 ...

  4. like to do vs like doing

    I like to eat apple 表示我喜欢吃苹果这种食物. I like eating apple 表示我喜欢吃苹果这种食物 或者 表示我喜欢吃苹果这个过程. like to do,表达的是倾 ...

  5. Sciter TIScript KeyEvent

    function movable() // install movable window handler{ function onKeyDown(evt) { if(evt.keyCode == Ev ...

  6. 有向连通图增加多少边构成强联通(hdu3836,poj1236)

    hdu3836 求出强分量后缩点处理得到分支图,对分支图的每个强连通分量统计出度和入度.需要的边数就是:统计 入度=0 的顶点数 和 出度=0 的顶点数,选择两者中较大的一个,才能确保一个强连通图. ...

  7. pandas numpy处理缺失值,none与nan比较

    原文链接:https://junjiecai.github.io/posts/2016/Oct/20/none_vs_nan/ 建议从这里下载这篇文章对应的.ipynb文件和相关资源.这样你就能在Ju ...

  8. window.onload的一些说明

    window.onload事件对于初学者来说,经常会让我们感觉不好理解,并且经常会犯一些错误,初学js的时候经常碰到有关于它的问题,我想和我一样很多初学者也会碰到,那时候不懂它的具体作用,只要一写代码 ...

  9. ASP.NET IIS System.UnauthorizedAccessException: 对路径“C:\......xls”的访问被拒绝。

    问题: System.UnauthorizedAccessException: 对路径“C:\.....xls”的访问被拒绝. 背景: 项目中用到Excel导出功能,用的是Excel模板的方式来做,意 ...

  10. POJ-1958 Strange Towers of Hanoi(线性动规)

    Strange Towers of Hanoi Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 2677 Accepted: 17 ...