APP完整开发(一)启动界面制作以及“延时函数”、“timer”使用

来源:互联网 发布:淘宝联盟手机设置 编辑:程序博客网 时间:2024/05/16 13:46

启动界面显示:

iPhone软件启动后的第一屏图片是非常重要的往往就是loading载入中的意思。设置它说来也简单,但是却无比重要

只需要在resource里面将你希望设置的图片更名为Default.png,这个图片就可以成为iPhone载入的缺省图片

启动界面的制作


iPhone开发实现splash画面非常简单,做一个全屏的欢迎页的图片,把它命名为Default.png,然后放在Xcode工程的Resource里面。
在XXXAppDelegate.m程序中,插入如下代码:
(BOOL)application:(UIApplication*)application
didFinishLaunchingWithOp
tions:(NSDictionary *)launchOptions {
 
 //–inserta delay of 5 seconds before the splash screendisappears–
 
 [NSThread sleepForTimeInterval:5.0]; //延时函数,表示延迟5秒后
 
 //Override point for customization after applicationlaunch.
 
 //Add the view controller’s view to the window anddisplay.
 
 [windowaddSubview:viewController.view];
 
 [windowmakeKeyAndVisible];
 
 return YES;
}

这样splash页面就停留5秒后,消失了。

————————————————————————————————————————————

延时函数和Timer的使用
延时函数:
[NSThread sleepForTimeInterval:5.0]; //暂停5s.


Timer的使用:
NSTimer *connectionTimer;  //timer对象


//实例化timer
self.connectionTimer=[NSTimerscheduledTimerWithTimeInterval:1.5 target:selfselector:@selector(timerFired:) userInfo:nil repeats:NO];
[[NSRunLoop currentRunLoop]addTimer:self.connectionTimer forMode:NSDefaultRunLoopMode];
//用timer作为延时的一种方法   
do{
[[NSRunLoopcurrentRunLoop]runUntilDate:[NSDatedateWithTimeIntervalSinceNow:1.0]];
}while(!done); 




//timer调用函数
-(void)timerFired:(NSTimer *)timer{
done =YES;
}

原创粉丝点击