1
votes

I'm presenting a modal view controller using following code,

[[mInfo objectForKey: kNavigationController] presentViewController:(UIViewController*)modalViewControlr animated:YES completion:nil];

UITableView. On selecting a table view cell I want to navigate it to another UIView called navigatedView.

Is this can be done by embedding self (i.e,modalViewControlr) in navigation Controller and add view (i.e, navigatedView) to a view controller and present it? for example,

// in modalViewControlr
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//

 UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:self];
        UIViewController *vc = [[UIViewController alloc]init];
        [vc.view addSubview:self.navigatedView];
        self.navigatedView.frame=vc.view.frame;
 [passcodeNavigationController pushViewController: vc animated:YES];

//

}

Please help....

1

1 Answers

0
votes

I prefer do it in this way which is easier to understand.

1.Embed the navigationController in AppDelegate:

ModalViewControlr *vc = [[ModalViewControlr alloc]init];
UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:vc];
self.window.rootViewController = passcodeNavigationController;

2.Create a new class NavigatedViewControllerand custom the controller in viewDidLoad

Create an UIView call navigatedView

@property (nonatomic, strong) UIView *navigatedView;

-(void)viewDidLoad
{
   [super viewDidLoad];
   _navigatedView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
   self.navigatedView.backgroundColor = [UIColor redColor];
   [self.view addSubView:self.navigatedView];
}

3.Then return to modalViewControlr where you want to push from.

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   NavigatedViewController *vc = [[NavigatedViewController alloc] init];
   [self.navigationController pushViewController:vc animated:YES];
}