prepare push segue from presentviewcontroller using xib ios7

288 views Asked by At

How can I prepare segue on button click from presentviewcontroller using XIB objective-c? I am trying billow given code but it not working.

PushViewController *puvc=[[PushViewController alloc]initWithNibName:@"PushViewController" bundle:nil];

UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:puvc];

[self.navigationController pushViewController:nvc animated:YES];
1

There are 1 answers

7
Pradumna Patil On
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"YOUR_SEGUE_NAME_HERE"])
    {
        YourViewController *vc = [segue destinationViewController];
        [vc setMyObjectHere:object];
    }
}

YOUR_SEGUE_NAME_HERE is identifier of segue you set in XIB file. This helped me. Hope it helps.

PushViewController *puvc=[[PushViewController alloc]initWithNibName:@"PushViewController" bundle:nil];

[self.navigationController pushViewController:puvc animated:YES];

Use this code

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