0

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

Vix Hunk
  • 303
  • 4
  • 17

3 Answers3

1

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];
}
Ushan87
  • 1,608
  • 8
  • 15
1

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];
}
Ahmed Z.
  • 2,329
  • 23
  • 52
0

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];
}
Franck
  • 742
  • 3
  • 11
  • No i did not! actually i am new with objective c. Can you explain how can i do that? – Vix Hunk May 06 '13 at 08:58
  • You first have to think about your navigation tree (UITabbarController, UINvavigationController, custom navigation)? You should read a little about that :-) Explain in few words won't be enough sorry. Read Erica Sadun's books, there are really interesting. – Franck May 06 '13 at 09:07