[英]Rotation of SubView according to it's superview
我使用带有自动布局支持的故事板创建了一个应用程序。 现在,我想在请求/响应上添加一个加载视图。 我已经通过这样的代码创建了加载视图
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;
现在的问题是它没有执行旋转。 它总是以纵向模式进入。 我该如何对其应用自动旋转功能。
也许这会帮助您尝试
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
我找不到从哪里开始为UIActivityIndicatorView设置动画。
[self.activityIndicator startAnimating];
用于loadView的最佳框架之一
您可以使用NetworkActivityIndicator
。
发送请求时,请使用
[self setNetworkActivityIndicatorVisible:YES];
当回复回来时,使用
[self setNetworkActivityIndicatorVisible:NO];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.