如何把activityviewicator中的一个tableview
我已经把活动指标
spinner.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2); [self.view addSubview:spinner];
但是这不是在表格视图中正确居中。 因为表格视图可以滚动。 我怎么能把一个微调在屏幕的中心。
尝试与波纹pipe的代码:
spinner.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2); yourAppdelegateClass *appDelegate = (yourAppdelegateClass*)[[UIApplication sharedApplication] delegate]; [appDelegate.window addSubview:spinner];
代码输出是: –
尝试这个:
spinner.center = tableview.center;
希望能帮助到你!!
我认为你应该添加你的指示器(微调)在表视图而不是sel.view。 并在指示器上定义区域框架。
希望这会帮助你。
我有另一个解决scheme,因为我必须在细节视图控制器放置一个微调。 也许这会帮助别人。
- (void)viewDidLoad { [super viewDidLoad]; self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; self.spinner.hidesWhenStopped = YES; [self.navigationController.view addSubview:self.spinner]; }
而对于定位:
-(void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; [self.navigationController.view setNeedsLayout]; [self.navigationController.view layoutIfNeeded]; self.spinner.frame = CGRectMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2, 10, 10); }
微调将永远在你的表视图的中心在细节视图控制器。
请find下面的代码:
UIActivityIndicatorView* spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; spinner.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2); AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate]; [spinner startAnimating]; [appDelegate.window addSubview:spinner];