0
-(void)btnclick1:(UIButton *)sender
{
    NSString *storyboardName=@"Main";

    UIStoryboard* storyboard1 = [UIStoryboard storyboardWithName:storyboardName
                                                         bundle:nil];


    secondViewController *add = [[secondViewController alloc]init];
 add =[storyboard1 instantiateViewControllerWithIdentifier:@"nextseg"];
    [self.view addSubview:add.view];

    [self presentViewController:add
                       animated:YES
                     completion:nil];



}

I got error: reason: 'Storyboard () doesn't contain a view controller with identifier 'nextseg''

Madhu M
  • 41
  • 1
  • 6
  • Do you give identifier to view controller in storyboard? In other words What is "nextseg" from where u get this? – CRDave Oct 27 '14 at 06:47
  • try this link http://stackoverflow.com/questions/23102978/swrevealviewcontroller-without-using-navigationcontroller/23105142#23105142 – Anbu.Karthik Oct 27 '14 at 07:03

2 Answers2

0

You need to set the Storyboard ID for the xib you want to use in the MainStoryboard Settings for the XIB, see image. In your case it should be @"nextseg"

enter image description here

Hope this helps.

Cheers.

iphonic
  • 12,615
  • 7
  • 60
  • 107
0

Just add [NSBundle mainBundle] to the bundle argument where you get the storyboard from. Hope this helps

-(void)btnclick1:(UIButton *)sender
{
    NSString *storyboardName=@"Main";

    UIStoryboard* storyboard1 = [UIStoryboard storyboardWithName:storyboardName
                                                     bundle:[NSBundle mainBundle]];


    secondViewController *add = [[secondViewController alloc]init];
    add =[storyboard1 instantiateViewControllerWithIdentifier:@"nextseg"];
    [self.view addSubview:add.view];

    [self presentViewController:add
                   animated:YES
                 completion:nil];



}

Also make sure you have a identifier "nextseg" for your view controller. "nextseg" should not be the identifier of the segue leading to the view controller, but it should be for the view controller

Aravind G S
  • 392
  • 3
  • 17