Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SunnyLi

Guest
Original poster
Oct 7, 2010
22
0
Hi Guys,

New here just wondered if you could help, my application runs fine in the simulator. But when i put it on my phone theres a slight delay on the text thats in the label ie it loads up about a second later.

Is there any way around this at all?

I appreciate your answers....


SunnyLi
 
Ive put the label in its own method like so:

Code:
-(void)updateLabel{
	self.datestart = [NSDate date];
	NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
	int unitFlags = NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
	NSDateComponents *components = [gregorian components:unitFlags fromDate:datestart toDate:xmasDate options:0];
	countdown.text = [NSString stringWithFormat:@"%02d "" %02d "" "" %02d "" %02d", components.day, components.hour, components.minute, components.second ];
	countdown.textColor = [UIColor blackColor];
	
}

But i just notice the music is the same and thats in the viewdidload.
 
Ah, sorry. Misread your OP. There's no button at all.

So, you're updating a label in a countdown loop of some kind. How are you calling updateLabel and how are you handling the loop? You say you also have music. How is that being played?
 
The updatelabel is called from a timer in the viewdidload method

Code:
NSDate *today = [NSDate date];
	NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
	NSDateComponents *yearComp = [gregorian components:(NSYearCalendarUnit) fromDate:today];
	NSInteger year = [yearComp year];
	
	
	NSDateComponents *comps = [[NSDateComponents alloc] init];
	[comps setYear:year];
	[comps setMonth:12];
	[comps setDay:25];
	[comps setHour:00];
	[comps setMinute:00];
	[comps setSecond:00];
	self.xmasDate = [gregorian dateFromComponents:comps];
	[comps release];
	
	[B]self.timer = [NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:@selector(updateLabel) userInfo:nil repeats:YES];	[/B]

the background music in here aswell

---edit---
i think i found the problem


scheduledTimerWithTimeInterval:(1.0)

but the musics slightly off still...
Code:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"good" ofType:@"mp3"];
	NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
	theAudio= [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
	
	[theAudio play];
	theAudio.numberOfLoops = -1;
	
	[filePath release];
	[fileURL release];
	
	[super viewDidLoad];
 
Cheers,

Realised i made a school boy error on that one, ive just cut the song down by a few seconds works fine now :)

thanks for the help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.