zoukankan      html  css  js  c++  java
  • 导航视图(二)

    UIPageViewController 分屏效果笔记,参考IOS开发指南。

    #import <UIKit/UIKit.h>
    
    @interface ViewController : UIViewController<UIPageViewControllerDataSource, UIPageViewControllerDelegate>
    {
        int pageIndex;
    }
    
    @property(strong, nonatomic) UIPageViewController *pageViewController;
    
    
    @end
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.view.frame = CGRectMake(0.0f, 0.0f, 300.0f, 400.0f);
        
        //  UIPageViewControllerTransitionStylePageCurl     翻书效果
        //  UIPageViewControllerTransitionStyleScroll       滑屏效果
        
        //  UIPageViewControllerNavigationOrientationHorizontal 水平方向
        //  UIPageViewControllerNavigationOrientationVertical   垂直方向
        self.pageViewController = [[UIPageViewController alloc]
                                   initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
        
        self.pageViewController.dataSource = self;
        self.pageViewController.delegate   = self;
        
        UIStoryboard *mainBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UIViewController *page0 = [mainBoard instantiateViewControllerWithIdentifier:@"page1"];
        
        NSArray *viewArray = @[page0];
        
        
        [self.pageViewController setViewControllers:viewArray direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
        
        [self.view addSubview:self.pageViewController.view];
        
        pageIndex = 1;
        
    }
    
    -(UIViewController*)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
    {
        pageIndex++;
        
        if(pageIndex > 2){
            pageIndex = 2;
            return nil;
        }
        
        UIStoryboard *mainBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        NSString *Id = [NSString stringWithFormat:@"page%i", pageIndex];
        
        NSLog(@"%@", Id);
        
        UIViewController *page = [mainBoard instantiateViewControllerWithIdentifier:Id];
        
        return page;
    }
    
    -(UIViewController*)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
    {
        pageIndex--;
        
        if(pageIndex < 0){
            pageIndex = 0;
            return nil;
        }
        
        UIStoryboard *mainBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        NSString *Id = [NSString stringWithFormat:@"page%i", pageIndex];
        
        NSLog(@"%@", Id);
        
        UIViewController *page = [mainBoard instantiateViewControllerWithIdentifier:Id];
        
        return page;
    }
    
    
    @end
  • 相关阅读:
    jpa @onetomany 级联查询时会有重复数据,去重问题
    jpa/hibernate @onetomany 使用left join 添加多条件,可以使用过滤器filters (with-clause not allowed on fetched associations; use filters异常信息)
    如何使用多数据源,同时使用jpa和jdbctemplate
    mysql中使用enum,如何获取所有可能的值
    jpa返回List<Map<String, Object>>相当于jdbctemplate的queryForlist
    git bash各种乱码问题,已解决
    Kafka学习整理五(Consumer配置)
    创建Kafka0.8.2生产者与消费者
    Kafka消费组(consumer group)
    Kafka学习之四 Kafka常用命令
  • 原文地址:https://www.cnblogs.com/Fredric-2013/p/5936477.html
Copyright © 2011-2022 走看看