UIView Orientation Landscape
i need to show a View that covers the whole screen. For that i use this code:
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" siz开发者_StackOverflow社区e:(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];
The problem is that i need to show on landscape mode because when the view is shown it appears on portrait mode (although the ipad is on landscape mode and the viewController too).
Any ideas?
Thanks
set transformation to your 'modalView
' like this:
self.modalView.transform = CGAffineTransformMakeRotation( ( 180 * M_PI ) / 360 );
and apply the same transformation to all the subview's inside the 'modalView
', I hope it should work.
Did you change shouldAutorotateToInterfaceOrientation on your viewController ?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
精彩评论