User |
Post |
4:38 pm
October 9, 2008
|
bobcubsfan
iCoder
|
|
Los Angeles
|
|
|
posts 52
|
|
|
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
|
Brandon
Admin
|
|
brandontreb
|
|
|
posts 87
|
|
|
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
{
// 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 52
|
|
|
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
|
|
|
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
|
|
|
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 52
|
|
|
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
|
Brandon
Admin
|
|
brandontreb
|
|
|
posts 87
|
|
|
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 52
|
|
|
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
|
|
|
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
|
|
|
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 52
|
|
|
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?
|
|