简体   繁体   English

如何呈现动态创建的视图控制器

[英]How to present a dynamically created view controller

I got a problem and i couldnt understand what to do. 我遇到了问题,我不知道该怎么办。

in my app - when user logins, there are 4 options 在我的应用程序中-用户登录时,有4个选项

1 - show him a dashboard screen; 1-向他显示仪表板屏幕;

2 - show him a default screen if its coming in response (there is a parameter for this containing screen name); 2-向他显示默认屏幕(如果响应)(此参数包含屏幕名称);

3 - show change plan scree if its parameter is on in response; 3-显示更改计划屏幕,如果其参数为响应;

4 - show change pin screen after user sets his plan. 4-用户设置计划后显示更改图钉屏幕。

now the problem is, how to go to default screen after setting his pin, as i dont knw screen name (view controller name, as it is dynamic, coming from server). 现在的问题是,在设置他的密码后如何转到默认屏幕,因为我不知道屏幕名称(查看控制器名称,因为它是动态的,来自服务器)。

Code

 NSLog(@"Default Screen %@", mClient.defaultScreen);
if([mClient defaultScreen] != (id)[NSNull null] || [mClient defaultScreen].length != 0 ) {
    NSLog(@"Going to push default screen : %@", mClient.defaultScreen);
    [self pushDefaultScreen:mClient.defaultScreen];

} else {

    NSLog(@"Default screen is nil, going to load dashboard");
    [mClient setUPProgressHUDForView:self.view withLable:@"Generating Dashboard" andMessage:@"Please Wait.."];
    for(UIView *subview in [self.scrollView subviews]) {
        [subview removeFromSuperview];
    }
    NSLog(@"-->    :::  Going to change here");
    [self generateDashboard];
}


if(![mClient.showSetPinScreen isEqual:[NSNull null]] && ![mClient.showSetPinScreen isEqualToString:EMPTY_STRING]) {
    NSLog(@"Parameter showSetPinScreen : %@", mClient.showSetPinScreen);
    if([mClient.showSetPinScreen    isEqualToString:STRING_VALUE_YES]) {
        NSLog(@"mClient.showSetPinScreen parameter value is Y");
        SetPinViewController *changePinViewController = [[SetPinViewController alloc] initWithNibName:@"SetPinViewController" bundle:nil];
        changePinViewController.isFromLogin = STRING_VALUE_YES;
        [self.navigationController pushViewController:changePinViewController animated:YES];
    } else {
        NSLog(@"mClient.showSetPinScreen parameter value is N");
    }

}


if(![mClient.showCardPlanScreen isEqual:[NSNull null]] && ![mClient.showCardPlanScreen isEqualToString:EMPTY_STRING]) {
    NSLog(@"Parameter showCardPlanScreen : %@", mClient.showCardPlanScreen);
    if([mClient.showCardPlanScreen isEqualToString:STRING_VALUE_ZERO]) {
        NSLog(@"Do nothing");
    } else if([mClient.showCardPlanScreen isEqualToString:STRING_VALUE_ONE] || [mClient.showCardPlanScreen isEqualToString:STRING_VALUE_TWO]) {
        NSLog(@"Show card plan screen %@", mClient.showCardPlanScreen);
        ChangePlanViewController *changePlanVoewController = [[ChangePlanViewController alloc] initWithNibName:@"ChangePlanViewController" bundle:nil];
        changePlanVoewController.isFromLogin = STRING_VALUE_YES;
        [self.navigationController pushViewController:changePlanVoewController animated:YES];
    }

或者,您可以在storyBoard上创建其中的4个,在带有segues的4个与其相关的视图的loadingView上创建,然后在您的调度方法中使用正确的标识符调用performSegue。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从不在情节提要中但以编程方式创建的视图控制器呈现位于“主”情节提要中的视图控制器? - How to present a view controller that is in the “main” storyboard from a view controller that isn't in the storyboard but is created programmatically? 如何更改当前视图控制器? - How to change the present view controller? 如何不显示查看 Controller 模态 - How to not present View Controller Modally 如何已经呈现一个视图控制器的视图控制器? - How to present view controller with one view controller alreadly be presented? 如何从另一个视图控制器呈现视图控制器 - How to present a view controller from another view controller 如何从分离的视图控制器中呈现视图控制器? - How to present a view controller from a detached view controller? 如何从底部呈现动画的视图控制器 - How To Present A view Controller animated from bottom 如何显示视图控制器上存在的UIButton - How to show UIButtons present on the view controller 如何呈现较小尺寸的视图控制器 - How to present a view controller with smaller size 如何将GKMatchmakerViewController呈现给呈现的视图控制器? - How to present GKMatchmakerViewController to presented view controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM