[英]Overlay not scrolling with UITableView - iOS
我有一個UITableView類,當轉到下一個屏幕時,該類使用以下方法來調用加載疊加層。 問題在於此加載屏幕不會隨列表一起滾動...因此,如果您滾動一點並單擊某項,則不會顯示加載屏幕(因為它在頂部)。 如何使加載屏幕始終保持在UITableView頂部? 請注意,每個UITableView都包含在UINavBar中,而UINavBar包含在UITabBar中。 這是我的代碼:
-(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];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.