Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 更改加载屏幕活动指示器的方向_Iphone_Ios_Loading - Fatal编程技术网

Iphone 更改加载屏幕活动指示器的方向

Iphone 更改加载屏幕活动指示器的方向,iphone,ios,loading,Iphone,Ios,Loading,在我的iPhone中,我使用了加载屏幕(UIView中的活动指示器),现在我正在将我的应用程序转换为通用应用程序。因此,我希望加载屏幕根据设备的方向进行更改。我已附上密码 -(void) loading { waitingBGView = [[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 568.0)]; [waitingBGView setBackgroundColor:[UIColor blackColor]]; [waitin

在我的iPhone中,我使用了加载屏幕(UIView中的活动指示器),现在我正在将我的应用程序转换为通用应用程序。因此,我希望加载屏幕根据设备的方向进行更改。我已附上密码

-(void) loading
{
waitingBGView = [[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 568.0)];
[waitingBGView setBackgroundColor:[UIColor blackColor]];
[waitingBGView setAlpha:0.5];

[appdelegate.window addSubview:waitingBGView];

smallBlackView = [[UIView alloc] initWithFrame:CGRectMake(([UIScreen mainScreen].bounds.size.width)/2 - 80, ([UIScreen mainScreen].bounds.size.height)/2 - 30, 160.0, 60.0)];
smallBlackView.layer.borderColor = [[UIColor whiteColor] CGColor];
smallBlackView.layer.borderWidth = 2.0;
smallBlackView.layer.cornerRadius = 7.0;
smallBlackView.backgroundColor = [UIColor blackColor];

activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[activityIndicator setFrame:CGRectMake(5.0, 5.0, 50.0, 50.0)];
[smallBlackView addSubview:activityIndicator];
[activityIndicator startAnimating];

UILabel *lblLoading = [[UILabel alloc]initWithFrame:CGRectMake(60.0, 0.0, 100.0, 60.0)];
lblLoading.backgroundColor = [UIColor clearColor];
lblLoading.font = [UIFont fontWithName:@"Helvetica" size:18.0];
lblLoading.textColor = [UIColor whiteColor];
lblLoading.text = @"Loading...";

[smallBlackView addSubview:lblLoading];
[appdelegate.window addSubview:smallBlackView];
}
如何更改代码,使视图相对于设备的方向发生变化

 activityIndicator.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin); 

希望这会有所帮助。

试试,activityIndicator.autoresizingMask=(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth | UIViewAutoResizingFlexibleLeLeLeLeLeftMargin | UIViewAutoresizingFlexibleRightMargin);
if (self.interfaceOrientation == UIInterfaceOrientationLandscape ||self.interfaceOrientation == UIInterfaceOrientationPortrait) {   
yourctivity.view.frame = CGRectMake(self.view.center, self.view.center, 30, 30);
}