0

pdf を含む UIviewController があります。別の画面の向きを使用して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];
}

どんな助けでも大歓迎です。ありがとうございました

4

1 に答える 1

0

この複雑なタスクを実行する代わりに、ios が提供するデフォルトのメソッドを使用して、オリエンテーションを処理する必要があります。

次のコードを.mファイルに追加するだけです。

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES;
}
于 2011-05-18T05:16:12.483 に答える