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

时间:2013-11-19 13:30:49

标签: ios view uiviewcontroller

我遇到了问题,我无法理解该怎么做。

在我的应用中 - 当用户登录时,有4个选项

1 - 向他展示仪表板屏幕;

2 - 如果它出现在响应中,则显示一个默认屏幕(包含此屏幕名称的参数);

3 - 如果其参数在响应中显示,则显示更改计划屏幕;

4 - 在用户设定计划后显示更改引脚屏幕。

现在的问题是,如何设置他的引脚后进入默认屏幕,因为我不知道屏幕名称(查看控制器名称,因为它是动态的,来自服务器)。

代码

 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];
    }

1 个答案:

答案 0 :(得分:0)

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