one nib file showing on another one

98 views Asked by At

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

3

There are 3 answers

0
Ushan87 On BEST ANSWER

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];
}
2
Franck On

Did you set a UINavigationController first? If yes you should try:

-(IBAction)dOne{
    SellAutoViewController *autoController = [[SellAutoViewController alloc] initWithNibName: @"SellAutoViewController" bundle: nil];
    [self.navigationController pushViewController:autoController animated:YES];
}
0
Ahmed Z. On

You could use modalTransition here using this code

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