0

一連のフィルターを適用している UITableView があります。「フィルター」ボタンをタップすると、ナビゲーションバーの下からフィルターがアニメーション化されます。ここで行っているのは、読み込んだNIBをUITableViewのスーパービューに追加することです。ビューを起動すると、これは完全に機能します。フィルター NIB を表示および非表示にすることができます。ただし、ホームボタンを押してアプリをバックグラウンドに送信した後、アプリを再度起動してフォアグラウンドに移動します。これで、ロードして UITableView のスーパービューにアタッチした NIB が画面を引き継ぎました。テーブルビューはこのビューの下に隠されています。フィルタ NIB を非表示にすることで、ヒットの小さなセクションを確認できます。スーパービューに追加した NIB の高さは 75 ですが、最前面に表示すると、フレームのサイズが 400 を超えていることがわかります。なぜこれがスーパービューで起こっているのかについて、誰かが何か考えを持っていますか? ありがとう

マイコード

- (IBAction)filterButtonPressed:(UIBarButtonItem *)sender
{
    //If the filter view is displayed on screen then remove it.
    if(self.filterViewDisplayed == YES){
        [self animateFilterButtonsWithButtonsYOrigin:-75 tableViewYOrigin:-75];
        self.filterViewDisplayed = NO;

    }else {
        //Determine if we should load the FilterButtons XIB
        if(self.filterViewLoaded == NO) {

            self.filterViewLoaded = YES;
            [self.tableView.superview addSubview:self.activityFilter];
        }
        self.filterViewDisplayed = YES;
        //Set the delegate of the ActivityFilter to self so that we can handle callbacks.
        self.activityFilter.delegate = self;

        //Set the intial frame of the filter buttons to be -75 pixels off the top of the screen
        CGRect filterFrame = self.activityFilter.frame;
        filterFrame.origin.y = -75;
        self.activityFilter.frame = filterFrame;

        //Now animate the filter buttons to appear at origin 0.
        [self animateFilterButtonsWithButtonsYOrigin:0 tableViewYOrigin:75];
    }
}

- (void)animateFilterButtonsWithButtonsYOrigin:(CGFloat)yOrigin tableViewYOrigin:(CGFloat)tableViewYOrigin
{
    [UIView animateWithDuration:0.25
                     animations:^{
                         CGRect filterFrame = self.activityFilter.frame;
                         filterFrame.origin.y = yOrigin;
                         self.activityFilter.frame = filterFrame;
                         [self adjustTableViewOriginBy:tableViewYOrigin];
                     }];
}

-(void)adjustTableViewOriginBy:(CGFloat)yOrigin
{
    CGRect tableFrame = self.tableView.frame;
    tableFrame.origin.y += yOrigin;
    self.tableView.frame = tableFrame;
}

スクリーンショット

  1. フィルターアニメーション前
  2. フィルター適用後
  3. バックグラウンドから起動した後 - ここに問題があります。Superview はビュー全体を占有します
  4. フィルターを非表示にすると、スーパービューの下にテーブルビューが表示されます

フィルターアニメーション前

フィルター適用後

バックグラウンド起動後

フィルターを非表示にすると、スーパービューの下に UiTableView が表示されます

4

1 に答える 1

0

アプリのメニューにECSlidingViewControllerを使用しています。ビューとの相互作用を無効にしているように見せるために、これが最上位ビューのスクリーンショットを撮ることを発見しました。この結果、最上位のビュー、つまりスーパービューに、ロードした NIB ファイルが含まれていました。これが私が見ていたものです。ECSlidingViewController のスクリーンキャプチャ機能を無効にすることで解決しました。

于 2013-01-24T11:25:45.513 に答える