星空网 > 软件开发 > 操作系统

只有第一次进入带导航视图

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

我只展示最后一张图了。

只有第一次进入带导航视图images/loading.gif' data-original="http://images2015.cnblogs.com/blog/868060/201603/868060-20160321195652683-1685728903.png" />

 

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

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




原标题:只有第一次进入带导航视图

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

天木国际:https://www.goluckyvip.com/tag/42449.html
天启通国际物流:https://www.goluckyvip.com/tag/42450.html
天然气:https://www.goluckyvip.com/tag/42451.html
天速达:https://www.goluckyvip.com/tag/42452.html
天速达国际:https://www.goluckyvip.com/tag/42453.html
天天跨境:https://www.goluckyvip.com/tag/42455.html
千岛湖绿城度假酒店的简介:https://www.vstour.cn/a/363185.html
深圳大湾区游轮夜景 深圳大湾区游轮夜景图:https://www.vstour.cn/a/363186.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流