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

  • Home
  • SEARCH
  • 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 6706993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:35:09+00:00 2026-05-26T07:35:09+00:00

I have a tableview in which, in the first row, I am trying to

  • 0

I have a tableview in which, in the first row, I am trying to initially add a static value to the detailtextlabel. So when the tableview is loaded initially, the detailtextlabel shows the default value. When I click on the detailtextlabel, it switches. I have added code that will switch the default value to another value. This is working properly.
This is my code:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    cell = [tableView cellForRowAtIndexPath:indexPath];
    switch (indexPath.row) {
        case 0:
            if ([cell.detailTextLabel.text isEqualToString:@"digital"]) {
                cell.detailTextLabel.text = @"analog";
                userdefaults = [NSUserDefaults standardUserDefaults];
                [userdefaults setObject:@"analog" forKey:@"clock"];
            }
            else {
                cell.detailTextLabel.text = @"digital";
                [userdefaults setObject:@"digital" forKey:@"clock"];
            }
            [userdefaults synchronize];
            break;

        default:
            break;
    }
}

But my problem is when the label is getting changed from digital to analog, the digital view controller, which is added as the first tab in the mainwindow, should get changed to an analog viewcontroller and when analog is changed to digital, the digital viewcontroller should be replaced by the analog view controller in the first tab.

//In the appdidfinish launching I have done this code, but it does not change the tabbar at runtime.

NSString *clockswitch = [[NSUserDefaults standardUserDefaults]objectForKey:@"clock"];
if ([clockswitch isEqualToString:@"digital"]) {
    DigitalClockViewController *dig = [[DigitalClockViewController alloc]init];
    //self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:0];
}
else
{
    AnalogClockViewController *ana = [[AnalogClockViewController alloc]init];
    //self.tabBarController.selectedViewController = [self.tabBarController.ana objectAtIndex:0];
}
  • 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-26T07:35:10+00:00Added an answer on May 26, 2026 at 7:35 am
    UITabBarController.viewControllers is an immutable array you need to make a mutable copy.
    
    NSString *clockswitch = [[NSUserDefaults standardUserDefaults]objectForKey:@"clock"];
    UIViewController *desiredController = nil;
    if ([clockswitch isEqualToString:@"digital"]) {
        desiredController = [[DigitalClockViewController alloc]init];
    }
    else {
        desiredController = [[AnalogClockViewController alloc]init];
    }
    NSMutableArray *controllersCopy = [self.tabBarController.viewControllers mutableCopy];
    [controllersCopy replaceObjectAtIndex:0 withObject:desiredController];
    self.tabBarController.viewControllers = controllersCopy;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am trying to default to having the first row in a tableView
I have a tableView with many values. I want to get the first indexPath.row
I have a tableView which has cells with phone numbers. The app is not
I have a view which I built in Interface builder with a tableview and
I have an app which contains a scrollview with several tableviews. Each tableview is
I have a tableview with large images that fill the cells and the row
I have a view which consists of a tableview and a navigation bar. For
I am trying to add animation for UIImages which are added in an array.
So I have a Titanium.UI.tableview in my main window in my tab group which
I have encountered a really puzzling bug. The first row of my UITableView returns

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.