![](/img/trans.png)
[英]IOS - How to draw a border and a shadow that rotates with view but doesn't scale with it
[英]UIViewController rotates view but doesn't resize it
我最近在我的iOS游戏中添加了UIViewController,但遇到了一些困难。 我已将视图添加到视图控制器,并且在旋转手机时,视图旋转以保持直立。 我的问题是,当该视图处于横向时,该视图保持在纵向模式,底部位于屏幕外,屏幕右侧未绘制任何内容。
这是我的UIViewController的代码:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
CGRect screenBounds = [[UIScreen mainScreen] bounds];
_glView = [[[OpenGLView alloc] initWithFrame:screenBounds] autorelease];
[self.view addSubview:_glView];
}
return self;
}
我该如何解决?
我不确定您的OpenGLView类是什么,但是如果这是某些UIView派生类,则可以尝试将autoresizingMask
的_glView
设置为(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.