TextView Text Won't Set After Segue

Discussion in 'iOS Programming' started by Wellington2k, Mar 18, 2012.

  1. Wellington2k macrumors regular

    Joined:
    Jun 4, 2011
    #1
    Hello.

    I've got some code that sets the textview.text in a separate function:
    Code:
    -(void)settext {
    textview.text = @"Hi";
    }
    And I call it in ViewDidLoad:
    Code:
    [self settext];
    And when I press a button it switches to a new view controller:
    Code:
    -(IBAction)switch {
    [self performSegueWithIdentifier:@"GoNew" sender:NULL];
    }
    I use the same performSegue code in the other view controller to go back to the first, but when it goes back the textview refuses to set its text.

    Any help?
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    Your view is still in memory, so it won't reload the NIB (viewdidload is loaded when it loaded the NIB/XIB, whatever).
    Change your settext to viewWillAppear. Then it should set each time :)
     
  3. Wellington2k, Mar 19, 2012
    Last edited: Mar 19, 2012

    Wellington2k thread starter macrumors regular

    Joined:
    Jun 4, 2011
    #3
    Thanks for your help, it works now!

    That's some nice info!
     

Share This Page