user3693546
user3693546

Reputation:

How do we assign object into `UINavigationController` without pushing a ViewController object into it.?

How do we assign object into UINavigationController without pushing a ViewController object into it. Why do I need it is here :

I have total three Segment views and one of the segment is this that I am adding as subView :

-(void)Frds{
    [self clearSubView];
    obj = [[Frds alloc]initWithNibName:@"Frds" bundle:nil];
    [obj.view setFrame:CGRectMake(0, 65, 320, 568)];
    [self.view addSubview:obj.view];
}

and from Frds class when I access self.navigationController. It returns me nil, and it should obviously since I have not pushed the ViewController into it.

So, What is the way to access navigationController in Frds class after adding 'Frds' class object view as a 'subview' from forwarding class.

Upvotes: 3

Views: 259

Answers (1)

Alok
Alok

Reputation: 25948

You can add your frnd View object on rootviewController view object . First assign one rootviewcontroller on your navigation controller then you can easily add your view on it .

For assigning root view controller on navigation controller :

UINavigationController *navigationController=[[UINavigationController alloc] initWithRootViewController:detailViewController];

Use this method to find your root view controller:

UIViewController *rootViewController = self.navigationController.viewControllers[0];

Upvotes: 3

Related Questions