ios开发-引导页实现
来源:互联网 发布:淘宝订单申请售后时间 编辑:程序博客网 时间:2024/05/17 04:08
好久没写博客了,最近事情比较多,各种实验,各种考试。蛋疼阿...
今天忙里偷闲,又折腾了会ios。突然想起我正在做的那个客户端没有引导页,自己也没什么头绪,就去问了问群里的大牛们。
我是这样形容的:
有帅哥美女值班么...
像一些应用那样,第一次打开,有几张图片介绍应用使用方法,功能的那个。
要怎么实现?
然后邪恶哥就告诉我那玩意叫引导页,晓得术语后,我就自己百度去了,在code4app上找到了一份不错的demo。 也很方便。下面纪录下使用方法。
这里是code4app上的demo的下载链接。
http://code4app.com/ios/Introduction-Tutorial-View/5164359d6803fa8b1a000001
下载后,可以看看demo,很简单,我也是一看就懂。
下面说说我整合到我的项目中的方法。
1.把下载的demo中的
MYIntroductionView.h
MYIntroductionView.m
MYIntroductionPanel.h
MYIntroductionPanel.m
这四个文件,再加上一些图像资源加到你的工程中去。(之后如果要修改图像等资源只要在相应位置修改就好了。这里只是师范,没做修改)。
2.在你的主界面(打开应用显示的第一个界面)
在对应的.h文件中引入头文件并且设置协议。
如我的是 mainView.h
//// mainView.h// softwareApp//// Created by 余龙泽 on 13-9-27.// Copyright (c) 2013年 余龙泽. All rights reserved.//#import <UIKit/UIKit.h>#import "MYIntroductionView.h"@interface mainView : UITabBarController<MYIntroductionDelegate>@end
3.在主界面对应的.m文件中加入如下代码。
如我的mainView.m
-(void)viewWillAppear:(BOOL)animated{ //读取沙盒数据 NSUserDefaults * settings1 = [NSUserDefaults standardUserDefaults]; NSString *key1 = [NSString stringWithFormat:@"is_first"]; NSString *value = [settings1 objectForKey:key1]; if (!value) //如果没有数据 { //STEP 1 Construct Panels MYIntroductionPanel *panel = [[MYIntroductionPanel alloc] initWithimage:[UIImage imageNamed:@"SampleImage1"] description:@"Welcome to MYIntroductionView, your 100 percent customizable interface for introductions and tutorials! Simply add a few classes to your project, and you are ready to go!"]; //You may also add in a title for each panel MYIntroductionPanel *panel2 = [[MYIntroductionPanel alloc] initWithimage:[UIImage imageNamed:@"SampleImage2"] title:@"Your Ticket!" description:@"MYIntroductionView is your ticket to a great tutorial or introduction!"]; //STEP 2 Create IntroductionView /*A standard version*/ //MYIntroductionView *introductionView = [[MYIntroductionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) headerImage:[UIImage imageNamed:@"SampleHeaderImage.png"] panels:@[panel, panel2]]; /*A version with no header (ala "Path")*/ //MYIntroductionView *introductionView = [[MYIntroductionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) panels:@[panel, panel2]]; /*A more customized version*/ MYIntroductionView *introductionView = [[MYIntroductionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) headerText:@"MYIntroductionView" panels:@[panel, panel2] languageDirection:MYLanguageDirectionLeftToRight]; [introductionView setBackgroundImage:[UIImage imageNamed:@"SampleBackground"]]; //Set delegate to self for callbacks (optional) introductionView.delegate = self; //STEP 3: Show introduction view [introductionView showInView:self.view]; //写入数据 NSUserDefaults * setting = [NSUserDefaults standardUserDefaults]; NSString * key = [NSString stringWithFormat:@"is_first"]; [setting setObject:[NSString stringWithFormat:@"false"] forKey:key]; [setting synchronize]; }}
代码不难。
viewWillAppear是在视图即将显示时候调用的方法。 这里看头寻找沙盒中 is_first中是否有数据,如果没有,就说明是第一次运行程序,则显示引导页并且在沙盒对应位置写入数据。
如果有数据,就说明不是第一次运行,则跳过,不显示引导页。
很简单的操作。当然有更好的方法,也有更好的类库,这只是我个人选择的方法罢了。
学习的路上,与君共勉。
- ios开发-引导页实现
- ios开发-引导页实现
- IOS开发:引导页的实现
- ios开发——简单引导页的实现
- iOS开发基础 - 引导页
- iOS开发---引导页设置
- iOS App 引导页开发
- iOS用户引导页的简单实现
- iOS引导页实现(一)
- ios UIPageViewController+pageControl实现引导页
- iOS新手引导页的实现,源码
- iOS 一步一步带你实现引导页
- ios基于UIScrollView实现滑动引导页
- iOS 中引导页的实现
- IOS开发 - 引导页的两种实现 - UICollectionView和UIScrollView
- ios 实现引导页面效果
- ios 实现引导页面效果
- iOS开发 ----- 自动循环滚动或引导页效果
- 删除文件中的 ^M 字符
- asp.net发布到IIS: 无法识别的属性“targetFramework”。请注意属性名称区分大小写
- clientX,clientY,pageX,pageY,screenX,screenY的区别
- html5之viewport
- Spring Web应用的最大瑕疵
- ios开发-引导页实现
- excel中如何设置下拉框,并且不同值显示不同颜色
- JAVA编程思想第四版-多线程的练习答案之练习18
- 数据结构之链表
- C++ 前景
- JAVA编程思想第四版-多线程的练习答案之练习19
- hdu 2458 Kindergarten 匹配
- NSLocale的一些方法
- Emacs for Linux安装指南