In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to implement countdown timer in ios. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
The effect of this countdown timer is as follows:
After setting the time of UIDatePicker as the remaining time, click the start button to start timing. UIDatePicker modifies the remaining time every 60s.
The code is as follows:
@implementation JoyViewController
NSTimer* timer;
NSInteger leftSeconds;
- (void)viewDidLoad
{
[super viewDidLoad];
//Set to use Count Down Timer mode
self.countDonwn.datePickerMode = UIDatePickerModeCountDownTime;
}
-(IBAction)clicked:(id)sender
{
//Get remaining time of settings
leftSeconds = self.countDown.countDuration;
//disable UIDatePicker control
self.countDown.enabled = NO;
//disable start button
[sender setEnabled] = NO;
//initialize a string to be used as the contents of the warning box
NSString *message = [[NSString stringWithFormat:@"Start countdown? You have [ %d] seconds left ",leftSeconds];
//Create a UIAlertView
UIAlartView * alert = [[UIAlartView alloc]initWithTitle:@"Start countdown? "
message:message
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
//Enable timer to execute tickdown method every 60s
timer = [NSTimer scheduledTimerWithTimeInterVal:60
targer:self selector:@selector(tickDown)
userInfo:nil repeates:YES];
}
- (void) tickDown
{
//Reduce the remaining time by 60s
leftSeconds -= 60;
//modify the remaining time of UIDatePicker
self.countDown.countDownDuration = leftSeconds;
if(leftSeconds
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.