2011-02-28 79 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