Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6159775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:11:20+00:00 2026-05-23T21:11:20+00:00

I have the following code that works for a Timer view. The problem is,

  • 0

I have the following code that works for a Timer view.

The problem is, when I change segments, while the timer is already running, the label resets, but the button text still stay’s stop, I need it to stay “start” instead. I tried doing it manually by doing self.timer.titleLabel.text = @"Start"; but for some reason it shows as "S...t" instead of "Start".

- (IBAction)startStop:(UIButton *)sender 
{
    if ( self.myTimer ) 
    {
        [self.myTimer invalidate];
        self.myTimer = nil;

        [sender setTitle:@"Start" forState:UIControlStateNormal];
    } 
    else 
    {
        self.myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(handleTimer:) userInfo:nil repeats:YES];
        [sender setTitle:@"Stop" forState:UIControlStateNormal];
    }
}

- (void)handleTimer:(NSTimer *)timer 
{
    self.counter--;
    self.timerLabel.text = [NSString stringWithFormat:@"%ld", self.counter];

    if ( self.counter <= 0 ){
        [self.myTimer invalidate];
        self.myTimer = nil;
    }
}

- (IBAction)reset:(id)sender 
{
    self.counter = self.counterSegment;
    self.timerLabel.text = timerCount;
}

- (void)segmentedControl:(SVSegmentedControl*)segmentedControl didSelectIndex:(NSUInteger)index
{
    if ( self.myTimer ) 
    {
        [self.myTimer invalidate];
        self.myTimer = nil;
        self.timer.titleLabel.text = @"Start";
    }   
    if (index == 0)
    {
        NSLog(@"15 sec");
        self.timerCount = @"15";
        self.counterSegment = 15;
    }
    else if (index == 1)
    {
        NSLog(@"30 sec");
        self.timerCount = @"30";
        self.counterSegment = 30;
    }
    else if (index == 2)
    {
        NSLog(@"60 sec");
        self.timerCount = @"60";
        self.counterSegment = 60;
    }
    self.counter = self.counterSegment;
    self.timerLabel.text = timerCount;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:11:21+00:00Added an answer on May 23, 2026 at 9:11 pm

    If the button label reads “S…t” instead of “Start”, then you need to make the font smaller or invoke adjustsFontSizeToFitWidth, e.g.

    button.titleLabel.font = [UIFont systemFontOfSize: 10];
    

    or

    button.titleLabel.adjustsFontSizeToFitWidth = YES;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: Bear in mind that while this code works on
I have the following code that works on PHP5 to send a HTTP POST
I have the following code that works on Firefox and Chrome $("#adicionarItem").click(function(){ $.ajax({ type:
I have the following code that works fine in IE: <HTML> <BODY> <script language=JavaScript>
I have the following code that compiles and works well: template<typename T> T GetGlobal(const
I have some JavaScript code that works in IE containing the following: myElement.innerText =
I have code that looks like the following, which works fine for displaying the
I have following code that does not work due to a being a value
I have following code snippet that i use to compile class at the run
I have the following code that shows either a bug or a misunderstanding on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.