如何将数据传递到Segue下一个viewController
问题描述:
我正在使用第三方SDK,它自带了一个viewController。如何将数据传递到Segue下一个viewController
所以,我做的是,我只是打电话。
PHViewController *vc = [[PHViewController alloc] init];
[self presentViewController:vc animated:YES completion:nil];
去viewController。
但是,我确实需要传递一些数据到这个PHViewController。我怎么做?因为如果我有故事板,我有prepareForSegue和perFormSegueWithIdentifier函数传递数据到下一个viewController,但在这个我没有。
答
没有情节提要:
[DestinationViewController *vc = [[DestinationViewController alloc] init];
vc.myData = toBePassedData
[self presentViewController:vc animated:YES completion:nil];
随着情节提要:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
guard let destVC = segue.destinationViewController as? DestinationViewController else {
return
}
destVC.myData = self.toBePassedData
}
以上是对斯威夫特的故事板,但你会明白其中的含义。
什么是数据?简单的字符串?一个图像 ? –
'PHViewController'是否具有可以设置的属性? ...或者一些接受数据的方法来调用? –
是像图像和文本字段数据的数据。 @PhillipMills:不会..哦,所以如果我可以通过编辑原始的SDK文件来创建该功能!谢谢! – progammingBeignner