2011-11-04 41 views
0

在我的應用程序我有一個後臺函數緩存數據 - 工作正常。 我已經實現了UIView * cacheProgressView;這是緩存機制的進展的可視指示。 (它包含UIProgressBar和這樣)shouldAutorotateToInterfaceOrientation從代理

因爲我想在我的所有的應用視圖來顯示這一點(很多意見UINavigation)我已經加入這個我委託其照顧它相當好

[self.window addSubview:cacheProgressView]; 

問題是:當我旋轉設備,並且自cacheProgressView安裝於窗口和不是視圖我不能將其設置爲一個適當的位置 - 該委託的內下面的函數沒有被調用:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 

    NSLog(@"Rotation detected from the delegate"); 

    return YES; 
} 

我應該如何解決這個問題?

回答

2

您可以旋轉註冊通知...

[[NSNotificationCenter defaultCenter] addObserver:self 
      selector:@selector(didRotate:) 
      name:@"UIDeviceOrientationDidChangeNotification" object:nil]; 


- (void) didRotate:(NSNotification *)notification{ 
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 
    // do stuff 
} 
+0

完美,千恩萬謝 – chewy

相關問題