5

次の画面に移動するときに、次のメソッドを使用して読み込みオーバーレイを呼び出す 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];
}
4

1 に答える 1

5

UITableViewControllerを使用していますか?

テーブルビュー自体ではなく、オーバーレイビューをテーブルのスーパービューに追加することで、問題を修正できるはずです。このように、オーバーレイは実際には上にあり、スクロールテーブルビューから分離されています

-(void)showActivityIndicator
{ 
    [[self.view superview] addSubview:overlay];
    [loading startAnimating];
}
于 2012-05-03T00:12:04.753 に答える