一个nib文件显示在另一个上

时间:2013-05-06 08:41:32

标签: iphone ios objective-c vin

我正在开发一款适用于iphone的vin代码扫描程序。一切顺利,但当我尝试打开一个笔尖时,它显示在我的另一个nib文件上。这是我的按钮代码,它启动了新的nib文件。

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

这是我在SellAutoViewController.m中所做的,我使用shoulautorotate函数以纵向模式显示它但没有发生任何事情

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

这里是点击完成按钮之前的视图,它将加载SellAutoViewController https://www.dropbox.com/s/8ssi4n50dcaqf28/Screenshot%202013.05.06%2013.26.54.png 这是当我点击完成按钮时发生的事情。 :( https://www.dropbox.com/s/q6z6a4dr0n198n3/Screenshot%202013.05.06%2013.27.13.png

3 个答案:

答案 0 :(得分:1)

用以下方法替换你的dOne方法

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

答案 1 :(得分:1)

您可以使用此代码

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

答案 2 :(得分:0)

您是否先设置了UINavigationController? 如果是,你应该尝试:

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