iPhone modal view inside another modal view?

前端 未结 3 1915
夕颜
夕颜 2020-12-17 05:07

My App uses a modal view when users add a new foo. The user selects a foo type using this modal view. Depending on what type is selected, the user needs to be asked for more

相关标签:
3条回答
  • 2020-12-17 05:47

    You need to take care on which instance you invoke the presentModalViewController when you deal with several levels of modal controllers. Let's suppose you have :

    [myControllerA presentModalViewController:myControllerB animated:YES];

    Next time you want to display a modal controller while B has the focus, you should invoke

    [myControllerB presentModalViewController:myControllerC animated:YES];

    in order to get the parent controller properly set. The hierarchy of controllers is then A-> B -> C

    0 讨论(0)
  • 2020-12-17 05:52

    Fixed. I got the behavior I wanted by pushing the second view controller to the first view controller's UINavigationController.

    creation of 1st modal view

    FooAddController *addController = [FooAddController alloc]
        initWithNibName:@"FooAddController" bundle:nil];
    addController.delegate = self;
    addController.foo = newFoo;
    UINavigationController *navigationController = [[UINavigationController alloc]
        initWithRootViewController:addController];
    [self presentModalViewController:navigationController animated:YES];
    [addController release];
    

    creation of 2nd modal view (in FooAddController)

    FooAddSizeViewController *addSizeController = [[FooAddSizeViewController alloc]
        initWithNibName:@"FooAddSizeViewController" bundle:nil];
    addSizeController.delegate = self;
    addSizeController.foo = self.foo;
    [self.navigationController pushViewController:addSizeController animated:YES];
    [addSizeController release];
    
    0 讨论(0)
  • 2020-12-17 05:54

    Did you try calling presentModalViewController on self.navigationControllerin both steps?

    0 讨论(0)
提交回复
热议问题