我有一个带有pdf的UIviewController。我在另一个屏幕中使用方向来显示pdf。该方向运作良好三次,然后应用程序挂起以下警告。
[切换到进程11779线程0x0]
[切换到处理13059主题0x0]
[切换到进程11779线程0x0]
它是什么意思? 请找到以下代码。
- (void)viewDidLoad
{
self.view.backgroundColor = [UIColor clearColor];
pdfURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"pdf"]];
[webView loadRequest:[NSURLRequest requestWithURL:pdfURL]];
thisDevice = [UIDevice currentDevice];
[thisDevice beginGeneratingDeviceOrientationNotifications];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:UIDeviceOrientationDidChangeNotification object:nil];
[self setTitle:@"1 Of 1"];
[super viewDidLoad];
}
-(void) detectOrientation
{
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {
//load view 2
IdcardVC *ids = [[IdcardVC alloc] initWithNibName:@"IdcardVC" bundle:nil];
[self.navigationController presentModalViewController:ids animated:YES];
[ids release];
}
else if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) {
[self dismissModalViewControllerAnimated:NO];
}
感谢任何帮助。 谢谢
答案 0 :(得分:0)
您应该使用ios提供的默认方法来处理方向内容,而不是执行此复杂任务:
只需将以下代码添加到您的 .m 文件中:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES;
}