Reputation: 99
I have 2 view controller
Main has a button
Detail has a label: lblDetail
I'm trying to pass data by segue : "sgPushDetail". When click on the button on Main, the label on Detail will be changed.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"sgPushDetail"]) {
DetailViewController *detail = segue.destinationViewController;
detail.lblDetail.text = @"you've already clicked";
}
}
But when i build, the label doesn't change. Please help me with this case!
Upvotes: 0
Views: 165
Reputation: 3085
The DetailViewController
is not loaded when you are setting value for the label in prepareForSegue
method. Do the following:
NSString
) in DetailViewController
viewDidLoad
method of your DetailViewController
, assign this property value to the label.Upvotes: 1