你的位置:首页 > 操作系统

[操作系统]只有第一次进入带导航视图


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

我只展示最后一张图了。

 

首先创建一个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

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