我有一个UIViewController,我必须将一个值(UIImage,NSString)传递给UINavigationViewController,我正在使用
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
AppDetail *advc = [segue destinationViewController];
if ([[segue identifier] isEqualToString:@"showDetail"]) {
advc.appTitel = name;
advc.appIcon = icon;
advc.detailAppName = detileName;
advc.appDescription = description;
advc.appDeveloper = developer;
}
}
将该值传递给
UIViewController
,如果我将其直接传递给UIViewController
,它可以完美地工作,但是我不能将其传递给UINavigationViewController
,有人知道我该怎么做吗?
最佳答案
我有一个来自Apple segue示例的示例代码。也许有帮助。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"Room Create"]) {
// Prepare the settings view where the user inputs the 'serviceType' and local peer 'displayName'
UINavigationController *navController = segue.destinationViewController;
SettingsViewController *viewController = (SettingsViewController *)navController.topViewController;
viewController.delegate = self;
// Pass the existing properties (if any) so the user can edit them.
viewController.displayName = self.displayName;
viewController.serviceType = self.serviceType;
}
}
关于ios - 如何将值传递给另一个UINavigationViewController,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19082090/