Subscribe ( )

iPhone Programming Tutorials

 

Forum

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

You must be logged in to post Login Register

Search 

Default.png

User Post

4:38 pm
October 9, 2008


bobcubsfan

iCoder

Los Angeles

posts 54

1

I created a default.png to be the “splash screen” when the app launches. But, I want to delay long enough (3 seconds) so users can read it before the app “launches.”

8:14 am
October 10, 2008


Admin

brandontreb

posts 87

2

Bob,


I would suggest using the NSTimer Object.

Something like this…


NSTimer *_timer = NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(onTimer) userInfo:nil repeats:YES

  • (void)onTimer

{

      // Put the code in here to push your next viewController
}


I hope this helps…

9:29 am
October 10, 2008


bobcubsfan

iCoder

Los Angeles

posts 54

3

I put in the following:

NSTimer *_timer;

@property (nonatomic, retain ) NSTimer *_timer;

-(void) onTimer;

@synthesize _timer;

[self  onTimer ];

-(void) onTimer {
    NSTimer *_timer = NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(onTimer) userInfo:nil repeats:YES;
}

And got these errors:

Warning: Line Location SQLiteTutorialAppDelegate.m:48: warning: unused variable '_timer'

error: Syntax error: Line Location SQLiteTutorialAppDelegate.m:48: error: syntax error before 'NSTimer'


11:39 am
October 10, 2008


Neil

iCoder

North Wales, UK

posts 6

4

You are redefining _timer in your onTimer method. Replace it with this:

_timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES];

11:39 am
October 10, 2008


Neil

iCoder

North Wales, UK

posts 6

5

You are redefining _timer in your onTimer method. Replace it with this:

_timer = [NSTimer scheduledTimerWithTimeInterval:3.0
                                            target:self
                                          selector:@selector(onTimer:)
                                          userInfo:nil
                                           repeats:YES];

12:44 pm
October 10, 2008


bobcubsfan

iCoder

Los Angeles

posts 54

6

thanks, no errors, but the timer has no effect, other than to hang my app after the second view loads.

I simply want to delay launching of my app after the default.png screen displays.


2:11 pm
October 10, 2008


Admin

brandontreb

posts 87

7

Hmmm…

Try this code

.h file….

NSTimer *_timer;

.m file…

@synthesize _timer;

… put this in one of the init methods

_timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES];

[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSDefaultRunLoopMode];

-(void) onTimer {

}

3:12 pm
October 10, 2008


bobcubsfan

iCoder

Los Angeles

posts 54

8

Brandon,


I appreciate that you are trying to help, but I simply cannot follow some of your instructions.

I put the code in the .h file and did the @property

I sythesized the variable in .m

I defined

_timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES];

in the Application did launch method.

I don't know were to add the 

[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSDefaultRunLoopMode];

nor the

-(void) onTimer {


}

method.


Sorry, but I am new at this.


3:30 pm
October 10, 2008


VertigoSol

Moderator

posts 26

9

loadview could work

-(void) loadView
{
[super loadView];
[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSDefaultRunLoopMode];


}

Wherever class you want events to happen you add the onTimer method example

_timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES];

if our target is self and self=MyClass.m
then add onTimer to MyClass.

3:32 pm
October 10, 2008


VertigoSol

Moderator

posts 26

10

add it to the root level delagate

-(void) applicationDidLoad
{
[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSDefaultRunLoopMode];

[window addSubview ......]

}

Wherever class you want events to happen you add the onTimer method example

_timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(onTimer:) userInfo:nil repeats:YES];

if our target is self and self=MyClass.m
then add onTimer to MyClass.

3:43 pm
October 10, 2008


bobcubsfan

iCoder

Los Angeles

posts 54

11

I get a syntax error before addtimer when I add this code

[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSDefaultRunLoopMode];

to ApplicationDidFinishLaunching

Why can't I simply put a 3 second delay loop in ApplicationDidFinishLaunching?


About the iCodeBlog forum

Currently Online:

3 Guests

Maximum Online: 44

Forums:

Groups: 2

Forums: 6

Topics: 335

Posts: 781

Members:

There are 755 members

There are 1 guests


Brandon has made 87 posts

Top Posters:

bobcubsfan - 54

crazyiez - 30

VertigoSol - 26

AdeC - 17

Uhu - 17

Administrator: Brandon | Moderators: VertigoSol


© - Version 3.1.4 (Build 357)