覆盖不滚动与UITableView – iOS

我有一个UITableView类,使用下面的方法来进入下一个屏幕时调用加载覆盖。 问题是,这个加载屏幕不滚动列表…所以,如果你滚动一下,点击一下,加载屏幕不显示(因为它在顶部)。 我怎样才能让加载屏幕始终保持在UITableView之上? 请知道每个UITableView都包含在UITabBar中包含的UINavBar中。 这是我的代码:

-(void)createLoadScreen { CGRect screenRect = [self.view bounds]; CGRect overlayFrame = CGRectMake(0.0, 0.0, screenRect.size.width, screenRect.size.height); overlay = [[UIView alloc] initWithFrame:overlayFrame]; overlay.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7]; CGRect frame = CGRectMake(screenRect.size.width / 2 - 25.0, screenRect.size.height / 2 - 70, 25.0, 25.0); loading = [[UIActivityIndicatorView alloc] initWithFrame:frame]; [loading setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge]; [loading sizeToFit]; loading.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); loading.hidesWhenStopped = YES; [overlay addSubview:loading]; } -(void)showActivityIndicator { [self.view addSubview:overlay]; [loading startAnimating]; } -(void)removeActivityIndicator { [loading stopAnimating]; [overlay removeFromSuperview]; } 

你使用UITableViewController吗?

您应该可以通过将叠加视图添加到表的超级视图而不是表视图本身来解决您的问题。 这样你的覆盖实际上和滚动表视图分开

 -(void)showActivityIndicator { [[self.view superview] addSubview:overlay]; [loading startAnimating]; }