ios中开始页面做法
- (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 <QuartzCore/QuartzCore.h> @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, ); // 设置分页
scrollView.pagingEnabled = YES;
// 隐藏水平的滚动条
scrollView.showsHorizontalScrollIndicator = NO;
// 去除弹簧效果
scrollView.bounces = NO; for (int index = ; 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 - ) {
// 让UIImageView跟用户进行交互(接收触摸事件)
imageView.userInteractionEnabled = YES; // 创建按钮
UIButton *btn = [[UIButton alloc] init];
btn.bounds = CGRectMake(, , , );
btn.center = CGPointMake(image.size.width * 0.5f, image.size.height - ); // 设置默认和高亮背景
[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:]; [imageView addSubview:btn]; // 监听按钮
[btn addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside]; [btn release];
}
}
} @end
ios中开始页面做法的更多相关文章
- ios中iframe页面出现白屏问题
最近用ionic3开发的一个项目在ios中出现了白屏的问题 banner轮播图跳转网页 使用了iframe 但是却时不时的出现白屏现象 在android中一切正常 网上查资料发现 是因为ios不允许访 ...
- [原]iOS中 Web 页面与 Native Code 的一种通信方式
在 iOS 开发中,Web 页面与 Native Code 通信可以分为两个方面: 1.Native Code 调用 Web 页面的方法:主要是调用页面中的 Javascript 函数. 2.Web ...
- iframe ios中h5页面 样式变大
实际项目开发中,iframe在移动设备中使用问题还是很大的,说一说我的那些iframe坑 做过的这个后台管理框架,最开始的需求是PC,但随着业务需要,需要将项目兼容到ipad,后台的框架也是使用的开源 ...
- iOS 中 h5 页面 iframe 调用高度自扩展问题及解决
开发需求需要在 h5 中用 iframe 中调用一个其他公司开发的 html 页面. 简单的插入 <iframe /> 并设置宽高后,发现在 Android 手机浏览器上打开可以正常运行, ...
- ios中滚动页面
- (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { int width=frame. ...
- 阻止iOS中页面弹性回滚,只允许div.phone_body的区块有弹性
使用说明:只要替换选择器:var selector = '.phone_body'; /** * 阻止iOS中页面弹性回滚,只允许div.scroller的区块有弹性 */ (function () ...
- ios系统微信浏览器、safari浏览器中h5页面上拉下滑导致悬浮层脱离窗口的解决方法
一. 运行环境: iphone所有机型的qq浏览器,safari浏览器,微信内置浏览器(qq浏览器内核)等. 二. 异常现象: 1. 大幅度上下滑动h5页面,然后停止滑动,有时候会影响到页面滚动,如局 ...
- iOS 一个app跳转另一个app并实现通信(如A跳到B并打开B中指定页面)
功能实现:A跳到B并打开B中指定页面 步骤: 1.首先创建两个项目(项目A,项目B),在项目B中的info.plist文件中添加URL Types,如下图所示:其中URL idenifier是项目B的 ...
- 谈谈iOS中的屏幕方向
众所周知,iOS中提供了[UIDevice currentDevice].orientation与[UIApplication sharedApplication].statusBarOrientat ...
随机推荐
- 基于libnids的TCP数据流的还原(多线程实现) .
我们知道,libnids本身可以实现TCP数据流的重组,但是如果一个TCP流数据量比较大的时候,就会分成好多个TCP报文段,这些报文段在网络中的传播可能是乱序的,利用libnids可以帮助我们按顺序接 ...
- 设置让php能够以root权限来执行exec() 或者 shell_exec()
一.查看启动你php的进程的用户是谁. 可以通过在命令行执行:ps -ef | grep php来看.或者在php中执行 echo exec('whoami') 来查看.centos下默认会是nobo ...
- Android -- EventBus解析
EventBus EventBus 是一个 Android 事件发布/订阅框架,通过解耦发布者和订阅者简化 Android 事件传递.传统的事件传递方式包括:Handler.BroadCastRece ...
- hdu 3665Seaside(简单floyd)
Seaside Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- JS调试必备的5个debug技巧_javascript技巧
JS调试必备的debug调试javascript技巧 1. debugger; 我以前也说过,你可以在JavaScript代码中加入一句debugger;来手工造成一个断点效果.需要带有条件的断点吗? ...
- Spatis service单元测试: 使用mock mapper的方式
转载:https://blog.csdn.net/atec2000/article/details/54346242 @RunWith(MockitoJUnitRunner.class)public ...
- 优雅地乱玩Linux-6-Chrome端SSH插件
文章最初发表于szhshp的第三边境研究所转载请注明 优雅地乱玩Linux-6-Chrome端SSH插件 最近注册了个AWS,免费一年,一年内可以各种乱玩~ 从自己的电脑连接云主机一般需要SSH这样的 ...
- 怎样让孩子爱上设计模式 —— 7.适配器模式(Adapter Pattern)
怎样让孩子爱上设计模式 -- 7.适配器模式(Adapter Pattern) 标签: 设计模式初涉 概念相关 定义: 适配器模式把一个类的接口变换成client所期待的还有一种接口,从而 使原本因接 ...
- 电脑技巧 如何保存网页为PDF
安装Adobe Acrobat X pro(要安装版本,不要绿色版),完成之后再打印机里面可以看到添加了新的Adobe PDF打印机 对于任意的Office文档,都可以直接打印到PDF得到PDF文 ...
- MySql 分区 分库 分表
ubuntu下MySQL配置和管理:http://www.2cto.com/database/201306/222510.html mysql分表,分区的区别和联系:http://my.oschina ...