zoukankan      html  css  js  c++  java
  • 只有第一次进入带导航视图

    只有第一次运行程序才出现 ,删除重新运行程序才会有。

    我只展示最后一张图了。

    首先创建一个viewcontroller的类

    然后在APPDelegate中设为根视图

    然后在

    UseGuideViewController.h中写

    FirstViewController是我的主界面。

     宏定义宽和高

    #import <UIKit/UIKit.h>
    #import "FirstViewController.h"
    #define WIDTH  self.view.frame.size.width
    #define HEIGHT self.view.frame.size.height
    
    @interface UseGuideViewController : UIViewController<UIScrollViewDelegate>
    
    @end
    

     下面的就是UseGuideViewController.m中的代码 ,有一些注释。

    #import "UseGuideViewController.h"
    
    @interface UseGuideViewController ()
    
    @end
    
    @implementation UseGuideViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        [self initGuide];
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    
    -(void)initGuide
    {
        UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
             [scrollView setContentSize:CGSizeMake(WIDTH*4, 0)];
            [scrollView setPagingEnabled:YES];  //视图整页显示
             //    [scrollView setBounces:NO]; //避免弹跳效果,避免把根视图露出来
             scrollView.delegate=self;
        
             UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
            [imageview setImage:[UIImage imageNamed:@"5.png"]];
            [scrollView addSubview:imageview];
        
        
             UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH, 0, WIDTH, HEIGHT)];
             [imageview1 setImage:[UIImage imageNamed:@"004.png"]];
             [scrollView addSubview:imageview1];
        
        
             UIImageView *imageview2 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH*2, 0, WIDTH, HEIGHT)];
             [imageview2 setImage:[UIImage imageNamed:@"006.png"]];
             [scrollView addSubview:imageview2];
        
        
            UIImageView *imageview3 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH*3, 0, WIDTH, HEIGHT)];
             [imageview3 setImage:[UIImage imageNamed:@"0.png"]];
             imageview3.userInteractionEnabled = YES;    //打开imageview3的用户交互;否则下面的button无法响应
             [scrollView addSubview:imageview3];
        
        
             UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];//在imageview3上加载一个透明的button
             [button setTitle:nil forState:UIControlStateNormal];
             [button setFrame:CGRectMake(250, 20, 150, 40)];
             [button addTarget:self action:@selector(firstpressed) forControlEvents:UIControlEventTouchUpInside];
        [button setTitle:@"进入主界面" forState:0];
        [button setTitleColor:[UIColor colorWithRed:0.305 green:1.000 blue:0.901 alpha:1.000] forState:0];
             [imageview3 addSubview:button];
        
             [self.view addSubview:scrollView];
        
         }
    
    - (void)firstpressed {
        FirstViewController *firstvc=[FirstViewController new];
        
        [self presentViewController: firstvc  animated:YES completion:^{
            NSLog(@"页面切换完毕.模态视图");
        }];
        
        }
    /*
    #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
    

     好了, 这个就是我简单的介绍了。或许不成熟, 但我为之努力。

  • 相关阅读:
    转dhdhtmlxTree
    转Merge的用法
    解决SqlServer2008评估期过期
    借鉴一下对比算法
    Asp.Net异常:"由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值"的解决方法
    查看Windows下引起Oracle CPU占用率高的神器-qslice
    今日有奖活动一览
    【分享】给做技术的战友们推荐一个不错的微信公号解解闷
    Unreal Engine Plugin management
    当在ECLIPSE中import现存项目时,如遇到版本不符
  • 原文地址:https://www.cnblogs.com/fume/p/5303432.html
Copyright © 2011-2022 走看看