UiLabeltext not changing !!!!

Discussion in 'iOS Programming' started by pragyanshis, Sep 27, 2011.

  1. pragyanshis macrumors newbie

    Joined:
    Sep 27, 2011
    #1
    I have defined a function in appdelegate like below.

    Code:
    - (void) ChangeLabelText:(NSString *)SenderP
    {
    TeenTaalViewControllerM = [[TeenTaalViewController alloc] initWithNibName:@"TeenTaalViewController" bundle:nil]; 
    TeenTaalViewControllerM.view.hidden= NO;
    [self.TeenTaalViewControllerM.lblLoopCountM setText:SenderP]; 
    self.TeenTaalViewControllerM.lblLoopCountM.hidden = NO; 
    }
    and I am calling this function from a class like below

    Code:
    TeenTaalAppDelegate * TheAppDelegateL = [[UIApplication sharedApplication] delegate];
    [TheAppDelegateL ChangeLabelText:@"Test"]; 


    But the text of the UIlabel is not changing anyway !!!!please help !!!
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    You are creating a NEW instance of your TeenTaalViewControllerM class. This will result in the label on your view the first time, and the label you are trying to assign will have 2 different memory adresses. This will result, in you maybe setting the label, but the wrong one behind the scenes ;)
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    What happens when you log TeenTaalViewControllerM.view in that method? Then try to think about why you get this result.
     

Share This Page