应用程序定向三次后挂起

发布于 2024-11-08 13:35:49 字数 1474 浏览 2 评论 0原文

我有一个 UIviewController ,里面有一个 pdf 。我使用另一个屏幕中的方向来显示 pdf。方向运行良好 3 次,然后应用程序挂起并出现以下警告。

[切换到进程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];
}

任何帮助表示赞赏。 谢谢

I have a UIviewController with a pdf in it. I use the orientation in another screen to display the pdf. The orientation works well three times and then the app hangs with the below warning.

[Switching to process 11779 thread 0x0]

[Switching to process 13059 thread 0x0]

[Switching to process 11779 thread 0x0]

What does it says?
Please find the code below.

- (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];
}

Any help is appreciated.
Thank You

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南城旧梦 2024-11-15 13:35:49

您应该使用 ios 提供的默认方法来处理方向问题,而不是执行这项复杂的任务:

只需将以下代码添加到您的 .m 文件中:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES;
}

Instead of doing this complicated task you should use the default method provided ios to deal with orientation stuff:

Just Add thee following code to your .m file:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文