문제

The issue that I am having is that when I try to pass data to the destinationViewController with a push segue, it looks as if its not getting passed. When I change the segue to a modal segue everything works perfectly.

[self performSegueWithIdentifier:@"segueToPlayCapturedMedia" sender:self];

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqual:@"segueToPlayCapturedMedia"]) {
        MediaPlayerViewController* mediaPlayerVC = segue.destinationViewController;
        mediaPlayerVC.fileURL = self.currentMediaFileURL;

        NSLog(@"on segue the recieved media file is  %@", mediaPlayerVC.fileURL);
    }
}

When I run it, I am able to NSLog the mediaPlayerVC.fileURL but when I try Logging the fileURL in viewDidLoad of the MediaPlayerViewController, the value is nil.

It almost seems to me that the instance of MediaPlayerViewController being displayed is different than the one created during the segue.

도움이 되었습니까?

해결책

Can you show the definition of your property fileURL in mediaPlayerVC.h It should be something like :

@property (strong, nonatomic) Type-mayBe-NSURL *fileURL;

strong is really important !

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top