首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIView方向概况

UIView方向概况
EN

Stack Overflow用户
提问于 2011-02-28 20:43:06
回答 2查看 3.6K关注 0票数 0

我需要显示一个覆盖整个屏幕的视图。为此,我使用以下代码:

代码语言:javascript
复制
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也是)。

有什么想法吗?

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-03-01 17:14:39

将转换设置为'modalView‘,如下所示:

代码语言:javascript
复制
self.modalView.transform = CGAffineTransformMakeRotation( ( 180 * M_PI ) / 360 );

并将相同的转换应用于'modalView‘中的所有子视图,我希望它能起作用。

票数 2
EN

Stack Overflow用户

发布于 2011-02-28 20:50:13

你在你的viewController上修改shouldAutorotateToInterfaceOrientation了吗?

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5142134

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档