user462455
user462455

Reputation: 13608

PresentViewController not presenting the view

-(void) switchtodetail{
    LocorecoDetailViewController *detail_view_controller = [[LocorecoDetailViewController alloc] init];
    [self presentViewController:detail_view_controller animated:YES completion:nil];
}

Above code doesn't present detail_view_controller. More info about LocorecoDetailViewController, it is the detail view controller template generated automatically when using Master-Detail application template

So I have a controller called SearchController which presents a modal view to add a question. Searchcontroller is the one which has switchtodetail function. Switchtodetail presents a modal controller, to add a question. After the question is added, I need to present a new view controller (detail view controller) So the flow is SearchController -> Add Question (Modal) -> after adding back to Searchcontroller -> LocorecoDetailViewcontroller. Last link is the broken one.

Upvotes: 0

Views: 3518

Answers (3)

Vipin Nair
Vipin Nair

Reputation: 515

Hi please specify the nib name which you want to load ,so change the line

 LocorecoDetailViewController *detail_view_controller = [[LocorecoDetailViewController alloc] init]; 

to

  LocorecoDetailViewController *detail_view_controller = [[LocorecoDetailViewController alloc] initWithNibName:@"LocorecoDetailViewController" bundle:nil];

And also remove the completion:nill part from the next code

Upvotes: 0

Minakshi
Minakshi

Reputation: 1433

If above two does not work, try this :

 -(void) switchtodetail{

      LocorecoDetailViewController *detail_view_controller = [[LocorecoDetailViewController alloc] initWithNibName:@"LocorecoDetailViewController" bundle:nil];
      [self presentModalViewController:detail_view_controller animated:YES];

}

I usually use this to present view controller. I think one of these three definitely help you to resolve your problem. All the best!

Upvotes: 3

Kapil Choubisa
Kapil Choubisa

Reputation: 5232

use:

[self presentModalViewController:detail_view_controller animated:YES];

Hope this will work.

Upvotes: 0

Related Questions