2
votes

My project has the following scenario:

[Preview View Controller] --(Modal)--> Navigation Controller --(Top)--> [Photo Setting View Controller]

In the [Preview View Controller], I have a button that will perform a modal segue (identifier="PreviewToSetting"), I have in my [Preview View Controller].m file define the prepareForSegue method:

- (void)prepareForSegue:(UIStoryboardSegue *) segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"PreviewToSetting"]) {
        UINavigationController *unc=segue.destinationViewController;
        PhotoSettingViewController *psvc=(PhotoSettingViewController *) unc.topViewController;
        psvc.lblAudio.text=@"TEST";
    }
}

I set the breakpoint in this procedure and did see the above block running without error. The segue does perform successfully and lead me to the "Photo Setting" scene, however the text of lblAudio was not set to "TEST" as I thought it should be, anyone knows why?

Some more information:

  • lblAudio is an UILabel Outlet property in PhotoSettingViewController (UITableViewController Subclass) in a static table cell within a table section
  • lblAudio is sycthesized and defined as

    @property (strong,nonatomic)IBOutlet UILabel *lblAudio;

  • The lblAudio IBOutlet is properly bind such that if I redefine the text property in viewWillAppear method like self.lblAudio.text=@"TEST", the label text will be properly get changed to "TEST".

1

1 Answers

0
votes

As the property is IBOutlet at time of segue it is not initialized. so try to do something like

Create one property for text of label like NSString *labelText and assign the value @"TEST" to that property and in viewWillAppear: method assign it to the label will do your work