Search code examples
iphoneiosobjective-cvin

one nib file showing on another one


i am developing a vin code scanner app for iphone. everything went well but when i try to open a nib it displays over my another nib file. here is my code for the button which launches new nib file.

-(IBAction)dOne{
    SellAutoViewController *autoController = [[SellAutoViewController alloc] initWithNibName: @"SellAutoViewController" bundle: nil];
    [self.view addSubview:autoController.view];
}

and here is what i did in my SellAutoViewController.m i use a shoulautorotate function to show it in portrait mode but nothing happened

-(BOOL)shouldAutorotate{
    return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
    return (UIInterfaceOrientationMaskPortrait);
}

here is the view before tapping Done button which will load SellAutoViewController https://www.dropbox.com/s/8ssi4n50dcaqf28/Screenshot%202013.05.06%2013.26.54.png and here is what happen when i tap Done button. :( https://www.dropbox.com/s/q6z6a4dr0n198n3/Screenshot%202013.05.06%2013.27.13.png


Solution

  • replace your dOne method with the below method

    -(IBAction)dOne{
        SellAutoViewController *autoController = [[SellAutoViewController alloc] initWithNibName: @"SellAutoViewController" bundle: nil];
        [self presentViewController:controller animated:YES completion:nil];
    }