So when a user clicks on a button in my app, I would like to create a new view with an activity indicator and cover the whole screen with it until the button action finishes.
因此,当用户单击我的应用程序中的一个按钮时,我希望创建一个带有活动指示器的新视图,并使用它覆盖整个屏幕,直到按钮操作完成。
However, my activity indicator view is covering only inside of a table view, it looks like this:
然而,我的活动指示器视图仅覆盖在表视图中,它看起来是这样的:
How to make it cover whole screen? Including the navigation controller and table view toolbar.
如何使它覆盖整个屏幕?包括导航控制器和表视图工具栏。
Here is my code I use to create the view:
下面是我用来创建视图的代码:
self.overlayView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.overlayView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
self.activityIndicator.center = self.overlayView.center;
[self.overlayView addSubview:self.activityIndicator];
[self.activityIndicator startAnimating];
[self.tableView addSubview:self.overlayView];
2 个解决方案
#1
21
Change
改变
[self.tableView addSubview:self.overlayView];
To
来
[self.navigationController.view addSubview:self.overlayView];
Set the overlay's rect accordingly.
相应地设置覆盖的rect。
#2
5
Do this:
这样做:
[[UIApplication sharedApplication].keyWindow addSubview:self.overlayView];
#1
21
Change
改变
[self.tableView addSubview:self.overlayView];
To
来
[self.navigationController.view addSubview:self.overlayView];
Set the overlay's rect accordingly.
相应地设置覆盖的rect。
#2
5
Do this:
这样做:
[[UIApplication sharedApplication].keyWindow addSubview:self.overlayView];