在我的应用程序中,我有15个屏幕。因为我在所有屏幕上都使用UIViewController
,所以在所有屏幕上我都使用以下方式调用其他屏幕:
AppDelegate *appRefre = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[self.navigationController pushViewController:appRefre.frmReferencesLink animated:YES];
并且以下代码在所有屏幕上均被激活以定向,以控制用户从一种方向切换到另一种模式
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
return YES;
}
else
{
return NO;
}
}
但是当我将iPhone设备从UIInterfaceOrientationPortrait
物理旋转到UIInterfaceOrientationPortraitUpsideDown
或UIInterfaceOrientationLandscapeLeft,UIInterfaceOrientationLandscapeRight
时,我的应用程序将被终止。
还有一件事是,当我启动应用程序时,我使用以下代码来启动我的应用程序:
1)我在mydelegate.h文件中创建了一个指针:
UINavigationController *navigationController;
然后合成其属性
@property(nonatomic,retain)UINavigationController *navigationController;
2)在mydelegat.m中我写
@synthesize navigationController;
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
navigationController = [[UINavigationController alloc] initWithRootViewController:DefaultViewLink];
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
}
3)在以上几点中,DefaultView首先启动,然后从视图中删除,然后实际将我的应用程序显示为图片。
因此,我希望我的应用程序在所有屏幕上都处于纵向模式,我不希望我的应用程序切换到其他模式。旋转到任何其他模式后,它都保持与纵向模式相同。
如果您不想允许您的应用程序以横向模式查看,则不要实现任何旋转功能。显然,您的代码存在某处错误,但是(我怀疑您必须已实现代码才能响应旋转事件),但是如果您不需要旋转设备,则只需删除此代码即可。
就像s1mm0t说的那样,您的代码中的其他地方肯定存在错误,这会导致应用崩溃。设备连接到计算机后,使用“构建和调试”运行您的应用程序。当它崩溃时,您可以查看调用堆栈并找到导致崩溃的代码。