Question

I have an app where a user can select the default tab they want loaded when they open the app. I have a settings table view controller that I've created in a storyboard. I have it set to static cells and created a cell that the user can press and uses a push segue to display another tableview with cells that the user can select to select the default tab. On the cell in the main settings table view, I have a label displaying the currently selected tab and the text of that label is set when the view is loaded. The problem I'm having is that when the user goes into the tab selecting table view, selects a tab, then returns to the main settings tableview, the -(void)viewDidLoad method doesn't get called. How can I call that method, or replicate the contents in that method in a new method the is called when the user returns to the main settings tableview?

Here is the code I currently have in my viewDidLoad method:

- (void)viewDidLoad
{
    [super viewDidLoad];


    NSUserDefaults *theDefaults = [NSUserDefaults standardUserDefaults];
    int theInt = [theDefaults integerForKey:@"defTab"];
    NSString *theString;
    switch (theInt) {
        case 0:
            theString = @"Home";
            break;
        case 1:
            theString = @"2D";
            break;
        case 2:
            theString = @"3D";
            break;
        case 3:
            theString = @"Calculator";
            break;
        case 4:
            theString = @"Extras";
            break;
        default:
            break;

    }

currentTabLabel.text = theString;
}

Thanks in advance.

Était-ce utile?

La solution

use:

-(void)viewDidAppear:(BOOL)animated {
    [self.tableView reloadData];
}

Autres conseils

use.

-(void)viewWillAppear:(BOOL)animated {
    [self.tableView reloadData];
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top