我有一个倒计时器,它在单元格中工作。我正在推细胞并显示DetailView控制器。在DetailViewController上,倒计时不起作用。 例如,在单元格中,我显示的倒计时看起来像| 23天14小时45分33秒|和工作。我正在推送单元格并在DetailViewController上显示像|的标签23天14小时45分32秒|但没有工作。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.label.text = self.tweetMessage;
self.username.text = self.userId;
self.count.text = self.countdownStartTime;
NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateTime)
userInfo:nil
repeats:YES];
}
-(void)updateTime
{
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
NSUInteger preservedComponents = (NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay);
self.datePicker.date = [calendar dateFromComponents:[calendar components:preservedComponents fromDate:self.datePicker.date]];
//Get the time left until the specified date
NSInteger ti = ((NSInteger)[self.datePicker.date timeIntervalSinceNow]);
NSInteger seconds = ti % 60;
NSInteger minutes = (ti / 60) % 60;
NSInteger hours = (ti / 3600) % 24;
NSInteger days = (ti / 86400);
//Update the lable with the remaining time
self.count.text = [NSString stringWithFormat:@"%02li days %02li hours %02li min %02li sec", (long)days, (long)hours, (long)minutes, (long)seconds];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"Continue"]){
DetailViewController *controller = (DetailViewController *)segue.destinationViewController;
controller.tweetMessage = ((TWTTweetTableViewCell *)sender).tweetMessage.text;
controller.userId = ((TWTTweetTableViewCell *)sender).user.text;
controller.countdownStartTime = ((TWTTweetTableViewCell *)sender).countdownTime.text;
}
}
答案 0 :(得分:0)
import "DetailViewController.h"
@interface DetailViewController ()
@end
@implementation DetailViewController
(void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view.
self.label.text = self.tweetMessage; self.username.text = self.userId; self.count.text = self.countdownStartTime;
NSTimer *timer; timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTime) userInfo:nil repeats:YES]; }
-(void)updateTime {
combobox
}
//Get the time left until the specified date
NSInteger ti = ((NSInteger)[self.datePicker.date timeIntervalSinceNow]);
NSInteger seconds = ti % 60;
NSInteger minutes = (ti / 60) % 60;
NSInteger hours = (ti / 3600) % 24;
NSInteger days = (ti / 86400);
//Update the lable with the remaining time
self.countdownTime.text = [NSString stringWithFormat:@"%02li days %02li hours %02li min %02li sec", (long)days, (long)hours, (long)minutes, (long)seconds];
Not working my Friend..