我尝试使用此代码,但它对我不起作用。 谢谢
-(void)passvar:(NSString *)user
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *viewController = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"signupvc"];
viewController.user = user;
[self presentViewController:viewController animated:YES completion:nil];
}
答案 0 :(得分:1)
void MyModernTab_SelectedSourceChanged(object sender, SourceEventArgs e)
{
if (e.Source.OriginalString.EndsWith("Foo.xaml"))
{
var url = "/Pages/Foo.xaml";
var bb = new BBCodeBlock();
bb.LinkNavigator.Navigate(new Uri(url, UriKind.Relative), this, NavigationHelper.FrameTop);
}
}
没有UIViewController
属性。
您应该使用自定义子类而不是user
UIVIewController
请注意,在此代码中,您从故事板中实例化 new -(void)passvar:(NSString *)user
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MyCustomViewController *viewController = (MyCustomViewController *)[storyboard instantiateViewControllerWithIdentifier:@"signupvc"];
viewController.user = user;
[self presentViewController:viewController animated:YES completion:nil];
}
并将其呈现给用户。它与您在调用这些代码行之前打开的任何其他View Controller无关
如果您将此功能调用3次,则会打开3个不同的MyCustomViewController
。