2011-05-18 21 views
0

我有一個帶有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

而不是做這個複雜的任務,你應該使用默認的方法提供IOS來處理方向的東西:

只是增加你下面的代碼到你的的.m文件

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