【发布时间】:2014-03-04 06:00:47
【问题描述】:
我使用带有自动布局支持的故事板创建了一个应用程序。现在我想在请求/响应上添加一个加载视图。我已经通过这样的代码创建了加载视图
self=[super initWithFrame:f];
[self setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.7]];
CGPoint p=[self center];
self.activityIndicator=[[UIActivityIndicatorView alloc] initWithFrame: CGRectMake(p.x-37/2, p.y-32/2, 37, 37)];
[self.activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
[self addSubview:self.activityIndicator];
lblMsg=[[UILabel alloc] initWithFrame:CGRectMake(p.x-50/2,CGRectGetMaxY(self.activityIndicator.frame), 200, 30)];
lblMsg.text=@"Logging...";
lblMsg.backgroundColor=[UIColor clearColor];
lblMsg.textColor=[UIColor lightGrayColor];
[self addSubview:lblMsg];
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
return self;
现在的问题是它没有执行旋转。它总是以纵向模式出现。我如何对其应用自动旋转功能。
【问题讨论】:
-
您的应用程序只支持横向模式??还是两者兼而有之??
-
确定这个加载视图是一个单独的 xib 文件?
-
不,我是通过代码创建的。这个没有xib。
-
ok,你写的是 YES to should autorotate 方法吗?
-
它是一个子视图,仅在视图控制器中自动旋转委托方法调用。
标签: ios storyboard subview autorotate