0

私は autolayout を使用しており、オプションを先頭のスペースをスーパービュー (定数 0) に設定し、末尾のスペースをスーパービュー (定数 0) に設定し、水平方向の中央をテーブル ビューのスーパービューに設定しました。

とはいえ、ランドスケープ モードから戻ると、テーブル ビューが移動可能になり、ドラッグすることができます。スーパービューの端に付いているようには見えません。ポートレートモードに戻ると、テーブルビューの右側に空白の部屋が残り、スペースを埋めることができなくなります。

私はすべての方向転換でこのコードを呼び出します:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    [General addLeftRightConstraintsToView:_detail1TableView inRelationToSuperview:self.navigationController.view];
}

これは、レイアウトの制約を更新するために使用しているクラス メソッドです。

+ (void)addLeftRightConstraintsToView:(UIView *)view inRelationToSuperview:(UIView *)superview
{

    // Left Space to Superview
    NSLayoutConstraint *leftSpaceConstraint =
    [NSLayoutConstraint constraintWithItem:view
                             attribute:NSLayoutAttributeLeft
                             relatedBy:NSLayoutRelationEqual
                                toItem:superview
                             attribute:NSLayoutAttributeLeft
                            multiplier:1.0
                              constant:0.0];

    // Right Space to Superview
    NSLayoutConstraint *rightSpaceConstraint =
    [NSLayoutConstraint constraintWithItem:view
                             attribute:NSLayoutAttributeRight
                             relatedBy:NSLayoutRelationEqual
                                toItem:superview
                             attribute:NSLayoutAttributeRight
                            multiplier:1.0
                              constant:0.0];

    [superview addConstraint:leftSpaceConstraint];
    [superview addConstraint:rightSpaceConstraint];

}

何か案は?

4

1 に答える 1

0

これは機能します:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    [_details2TableView reloadData];
}
于 2013-06-01T23:04:28.370 に答える