博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ios中开始页面做法
阅读量:6918 次
发布时间:2019-06-27

本文共 4867 字,大约阅读时间需要 16 分钟。

 

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];        id key = (id)kCFBundleVersionKey;        // 检测是否第一次使用这个版本        // 新浪微博-Info.plist    NSDictionary *info = [NSBundle mainBundle].infoDictionary;    // 获取当前软件的版本号    NSString *currentVersion = [info objectForKey:key];        // 从沙盒中取出版本号    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];    NSString *saveVersion = [defaults objectForKey:key];        // 不是第一次使用这个版本    if ([currentVersion isEqualToString:saveVersion]) {                //MJLog(@"不是第一次使用这个版本");        // 显示状态栏        application.statusBarHidden = NO;                IndexController *index = [[[IndexController alloc] init] autorelease];        self.window.rootViewController = index;            } else { // 第一次使用这个版本        // 更新沙盒中的版本号        [defaults setObject:currentVersion forKey:key];        // 同步到沙盒中        [defaults synchronize];                //MJLog(@"第一次使用这个版本");                // 显示版本新特性控制器        NewFeatureController *new = [[[NewFeatureController alloc] init] autorelease];        self.window.rootViewController = new;    }    [self.window makeKeyAndVisible];    return YES;}

 

 

 

#define kNewFeatureListName @"new_feature"#define kNewFeatureListExt @"plist"#import "NewFeatureController.h"#import "IndexController.h"#import 
@interface NewFeatureController ()@end@implementation NewFeatureController#pragma mark - 按钮点击- (void)start { UIApplication *app = [UIApplication sharedApplication]; // 显示状态栏 app.statusBarHidden = NO; IndexController *index = [[IndexController alloc] init]; // 设置窗口的根控制器 app.keyWindow.rootViewController = index; [index release]; // 执行动画 CATransition *anim = [CATransition animation]; anim.duration = 0.4; anim.type = kCATransitionPush; anim.subtype = kCATransitionFromRight; [app.keyWindow.layer addAnimation:anim forKey:nil];}#pragma mark - 生命周期方法- (void)loadView { // 不需要调用super的loadView // self.view默认是nil的,一旦发现view是nil,就会调用loadView方法大创建view // 这里会造成死循环 //self.view = [[UIScrollView alloc] initWithFrame:self.view.bounds]; // 控制器的view最适合的frame CGRect appFrame = [UIScreen mainScreen].applicationFrame; // 建议少用autorelease UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:appFrame]; self.view = scrollView; [scrollView release];}- (void)viewDidLoad{ [super viewDidLoad]; // 获取new_feature.plist的路径 NSString *path = [[NSBundle mainBundle] pathForResource:kNewFeatureListName ofType:kNewFeatureListExt]; // 加载new_feature.plist NSArray *array = [NSArray arrayWithContentsOfFile:path]; int count = array.count; // 设置scrollView的内容宽度 UIScrollView *scrollView = (UIScrollView *)self.view; scrollView.contentSize = CGSizeMake(count * scrollView.bounds.size.width, 0); // 设置分页 scrollView.pagingEnabled = YES; // 隐藏水平的滚动条 scrollView.showsHorizontalScrollIndicator = NO; // 去除弹簧效果 scrollView.bounces = NO; for (int index = 0; index< count; index++) { // 获取图片名称 NSString *imgName = [array objectAtIndex:index]; // 加载图片 UIImage *image = [UIImage imageNamed:imgName]; // 创建UIImageView UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; // 设置ImageView的x CGRect frame = imageView.frame; frame.origin.x = index * image.size.width; imageView.frame = frame; [self.view addSubview:imageView]; [imageView release]; // 添加"开始微博"按钮 if (index == count - 1) { // 让UIImageView跟用户进行交互(接收触摸事件) imageView.userInteractionEnabled = YES; // 创建按钮 UIButton *btn = [[UIButton alloc] init]; btn.bounds = CGRectMake(0, 0, 100, 35); btn.center = CGPointMake(image.size.width * 0.5f, image.size.height - 100); // 设置默认和高亮背景 [btn setNormalBg:@"new_features_startbutton_background.png" andHighlighted:@"new_features_startbutton_background_highlighted.png"]; // 设置按钮文字 NSString *title = NSLocalizedString(@"开始微博", nil); [btn setTitle:title forState:UIControlStateNormal]; // 设置按钮文字颜色 [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; // 设置按钮文字大小 btn.titleLabel.font = [UIFont systemFontOfSize:16]; [imageView addSubview:btn]; // 监听按钮 [btn addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside]; [btn release]; } }}@end

 

转载于:https://www.cnblogs.com/gcb999/p/3167966.html

你可能感兴趣的文章
android R文件相关问题
查看>>
设计模式:命令
查看>>
Chrom API 学习笔记
查看>>
Android findViewById与findViewWithTag()
查看>>
iOS call state change
查看>>
第二十一讲:tapestry的LinkSubmit等同于submit来使用
查看>>
python pickle模块的简单使用笔记
查看>>
观察者模式学习
查看>>
能挣钱的微信JSSDK+H5混合开发
查看>>
ionic实践教程
查看>>
互联网人的高考
查看>>
外部类名.this.方法名 /属性 用法理解 ---常用在内部类和匿名内部类
查看>>
【程序员小幽默5则】程序员的赚钱神器~~~
查看>>
MapReduce原理剖析
查看>>
linux常用命令 整理
查看>>
java线程池概念解析
查看>>
数据库事务特性以及隔离级别
查看>>
Java实现FTP相关操作
查看>>
关于JNI返回十六进制字符串到JAVA层的说明
查看>>
php中的类、对象
查看>>