2011-02-28 82 views
0

我需要顯示一個涵蓋整個屏幕的視圖。對於我使用此代碼:UIView方向風景

self.modalView = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 
self.modalView.opaque = NO; 
self.modalView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f]; 
CheckBookAppDelegate *delegate = (CheckBookAppDelegate *)[UIApplication sharedApplication].delegate; 

UIActivityIndicatorView *myIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 
myIndicator.center = CGPointMake(160, 240); 
[myIndicator startAnimating]; 
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease]; 
label.text = @"Enviando..."; 
label.textColor = [UIColor whiteColor]; 
label.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:(18.0)]; 
label.backgroundColor = [UIColor clearColor]; 
label.opaque = NO; 
[label sizeToFit]; 
[self.modalView addSubview:label]; 
[self.modalView addSubview:myIndicator]; 
[delegate.window addSubview:modalView]; 
[myIndicator release]; 

的問題是,我需要在橫向模式下顯示,因爲當顯示的視圖它出現在肖像模式(雖然iPad是景觀模式和的viewController太)。

任何想法?

感謝

回答

2

組變換你的「modalView」像這樣:

self.modalView.transform = CGAffineTransformMakeRotation((180 * M_PI)/360); 

和相同的變換應用到所有子視圖的的「modalView」裏面,我希望它應該工作。

1

你有沒有改變您的viewController shouldAutorotateToInterfaceOrientation?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 
+0

該代碼可能會讓您陷入麻煩 - 您應該明確檢查您想要支持的每個方向。如果有問題的用戶界面第一次進入橫向模式,那麼該代碼可能會中斷。 – occulus 2011-02-28 14:21:18

+0

是的,它不工作...任何想法? – xger86x 2011-02-28 22:45:29

+0

謝謝!!!它幫助了我 – Meir 2012-01-13 10:32:08