应用程序定向三次后挂起
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用 ios 提供的默认方法来处理方向问题,而不是执行这项复杂的任务:
只需将以下代码添加到您的 .m 文件中:
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: