新特性引导页

作者: laitys | 来源:发表于2016-06-08 11:55 被阅读175次
Paste_Image.png

在我们做程序维护和版本迭代工作中,我们经常会做新特性界面(闪屏页过后的引导界面),做新特性界面的逻辑思维就是在App被初次下载或版本升级之后才出现,一般到新特性界面的最后一页用户点击立即体验后,跳转到之前的业务逻辑界面,即未注册登录过的用户跳转到注册登录界面,登录过的用户,跳转到用户之前登录过停留的界面.

案例:

  • 判断应用的版本号是否更新
 ///  判断是否是新版本
 - (BOOL)isNewVersion{

 //获取Bundle文件夹下应用当前版本号
NSDictionary *infoDictionary = [NSBundle mainBundle].infoDictionary;
NSString *currentVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
 
 //偏好设置中获取上一次版本号
NSString *sandboxKey = @"sandboxKey";
NSString *sandboxVersion = [[NSUserDefaults standardUserDefaults]stringForKey:sandboxKey];
BOOL isNew = ![currentVersion isEqualToString:sandboxVersion];

 //如果是新版本号 保存到偏好设置
if (isNew) {
    [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:sandboxKey];
    [[NSUserDefaults standardUserDefaults]synchronize];
}

return isNew;
}
  • 在AppDelegate的didFinishLaunching里调用判断版本号是否更新方法 如果是跳到新特性控制器如果不是还走原来的业务逻辑.
    //判断是否是新版本 如果是则跳到新特性界面(视频导航页)
    if ([self isNewVersion]) {
    self.window.rootViewController = [[RTNewFeatureViewController alloc]init];
    }
    //如果不是新版本,根据自己的业务需求 提供一个方法确定window的根控制器
    [self switchWindowRootViewController];
  • 自定义新特性控制器
    @interface RTNewFeatureViewController () <RTNewFeatureCellDelegate,UICollectionViewDelegate,UICollectionViewDataSource>
    //流水布局
    @property (nonatomic, strong) UICollectionViewFlowLayout *layout;
    @property (nonatomic, strong) UICollectionView *collectionView;
    @property (nonatomic, strong) UIPageControl *pageControl;
    @end

     @implementation RTNewFeatureViewController
    
     static NSString * const reuseIdentifier = @"RTNewFeatureCell";
    
     - (void)viewDidLoad {
           [super viewDidLoad];
           [self prepareForUI];
           [[UIApplication sharedApplication]setStatusBarHidden:YES];
        }
    
      - (void)prepareForUI{
          [self.view addSubview:self.collectionView];
          [self.view addSubview:self.pageControl];
    
          [self.pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
             make.bottom.equalTo(self.view).offset(-15);
             make.centerX.equalTo(self.view);
          }];
    
          self.collectionView.delegate = self;
          self.collectionView.dataSource = self;
          self.collectionView.pagingEnabled = YES;
          self.collectionView.bounces = NO;
          self.collectionView.showsHorizontalScrollIndicator = NO;
          self.layout.itemSize = [UIScreen mainScreen].bounds.size;
          self.layout.minimumInteritemSpacing = 0;
          self.layout.minimumLineSpacing = 0;
          self.layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
         [self.collectionView registerClass:[RTNewFeatureCell class]  forCellWithReuseIdentifier:reuseIdentifier];
    
       }
    
         #pragma mark - UICollectionViewDataSource && DataSource
    
        - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
          return 2;
      }
    
     - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView      cellForItemAtIndexPath:(NSIndexPath *)indexPath {
            RTNewFeatureCell  *cell = [collectionView  dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
            cell.index = (int)indexPath.row;
            cell.delegate = self;
            return cell;
    }
    
         #pragma mark - RTNewFeatureCellDelegate
    
          ///  按钮点击事件
     -(void)cellButtonDidClick:(RTNewFeatureCell *)cell
        {
           AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
           NSIndexPath *indexPath = [self.collectionView indexPathForCell:cell];
           if (indexPath.row) {
                  //跳转到开始体验页
                 appDelegate.window.rootViewController = nil;
                 [[UIApplication sharedApplication]setStatusBarHidden:NO];
                 [appDelegate switchWindowRootViewController];
    
          }else{
                    //跳转到百度
              NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];
             [[UIApplication sharedApplication]openURL:url];
         }
    
       }
    
        ///  set pageControl
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
     {
           if(scrollView.contentOffset.x > [UIScreen mainScreen].bounds.size.width/2)
        {
             self.pageControl.currentPage = 1;
       }else{
             self.pageControl.currentPage = 0;
       }   
    }
    
       #pragma mark - lazyLoad
    
    - (UIPageControl *)pageControl
    {
         if (_pageControl == nil) {
             _pageControl = [[UIPageControl alloc]init];
             _pageControl.numberOfPages = 2;
             _pageControl.pageIndicatorTintColor = kRTColorWithHEX(0xC9C9C9, 1);
             _pageControl.currentPageIndicatorTintColor = kRTColorWithHEX(0xF88558, 1);
      }
            return _pageControl;
    }
    
    - (UICollectionView *)collectionView
     {
          if (_collectionView == nil) {
    
                 _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0,  self.view.bounds.size.width, self.view.bounds.size.height)  collectionViewLayout:self.layout];
    _collectionView.backgroundColor = [UIColor brownColor];
    
     }
          return _collectionView;
    }
    
      -(UICollectionViewFlowLayout *)layout
      {
             if (_layout == nil) {
                  UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
                  self.layout = layout;
             }
           return _layout;
      }
    

改变一下版本号测试一下

456.gif

相关文章

  •       新特性引导页

    在我们做程序维护和版本迭代工作中,我们经常会做新特性界面(闪屏页过后的引导界面),做新特性界面的逻辑思维就是在Ap...

  • 一行代码搞定引导页(新特性页)

    最近一直忙着找工作,入职, 简书也停了好久没更新了.如今尘埃落定, 该坚持的还是要继续坚持, 今天写一个新特性页的...

  • ios开发 新人引导设计/新功能/新特性引导页

    当我们开发app的一些新功能的时候,经常会有需求,要求我们引导用户去使用这些新功能,类似于下面的这种效果: 大家注...

  • iOS开发-新功能特性操作引导界面的实现最优方案(APP新功能使

    iOS开发新功能特性操作引导界面的实现最优方案 在APP开发中,为了引导用户熟悉APP的新功能特性,需要我们做新功...

  • iOS-新特性(引导图)

    新特性简介:当第一次下载打开程序后,会出现一组滑动图片,然后才打开程序(只有滑动到最后一个页面才能打开),以后打开...

  • 引导页

    // // ViewController.m // 引导页_课堂练习 // // Created by 张羽婷 o...

  • 引导页

    引导页是用户第一次使用app时,引导用户使用的页面,这个界面通常加载到进入界面的上面。我这个引导页是一个View,...

  • 引导页

    AppDelegate.m #import "AppDelegate.h" #import "ViewContro...

  • 引导页

    判断版本号 引导页界面 点击方法

  • 引导页

    引导页 引导页是在程序第一次安装的时候呈现出来的画面. 新建一个.pch.用于做程序中的声明.声明这几个变量 在 ...

网友评论

    本文标题:      新特性引导页

    本文链接:https://www.haomeiwen.com/subject/qoaddttx.html