Subscribe ( )

iPhone Programming Tutorials


 

Forum

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 88

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…

If debugging is the process of removing bugs, then programming must be the process of putting them in.
-Edsger Dijkstra

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 88

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 {

}

If debugging is the process of removing bugs, then programming must be the process of putting them in.
-Edsger Dijkstra

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.

e^i -1 =0

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.

e^i -1 =0

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?

Search 

About the iCodeBlog forum

Most Users Ever Online:

44


Currently Online:

5 Guests

Forum Stats:

Groups: 2

Forums: 6

Topics: 419

Posts: 893

Membership:

There are 934 Members

There has been 1 Guest

There are 2 Admins

There is 1 Moderator

Top Posters:

bobcubsfan – 54

crazyiez – 30

Uhu – 17

AdeC – 17

Nick – 15

jitesh61 – 12

Administrators: Brandon (88 Posts), Collin (0 Posts)

Moderators: VertigoSol (26 Posts)



©   

  • Posted by on 6 Aug 2008 in Uncategorized
  •   |  
  •   |  
  •   |  
  • Comments Off

Comments are closed.