【发布时间】:2011-11-13 17:06:13
【问题描述】:
我正在尝试编写一个倒计时到一周中的特定日期。 我想显示当前工作日和到星期三的剩余秒数。
我可以编写第一部分的代码,但即使在寻找解决方案半天后,我也无法处理第二部分。
这就是我现在拥有的:
- (void)viewDidLoad {
[countdownLabel setFont:[UIFont fontWithName:@"Helvetica" size:128.0]];
countdownLabel.text = @"What day ist it?";
[super viewDidLoad];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
[super dealloc];
}
-(void)updateLabel {
NSDateFormatter* theDateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[theDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[theDateFormatter setDateFormat:@"EEEE"];
countdownLabel.text = [theDateFormatter stringFromDate:[NSDate date]];
}
【问题讨论】:
标签: objective-c ios cocoa-touch time nsdate