2016-10-14 23 views
3

GIFに問題が表示されます。 下のコードは、スーパービューにビューを追加する方法と、スーパービューの一番下から表示する方法を示しています。このコードは、iOS 9では正常に動作し、iOS 10では正常に動作しません。UIVIewアニメーションがiOS 10で正しく動作しない

スライドアップアニメーションのアニメーションは適切ではありません。右から出てきて、下から真っ直ぐではなく角度をつけています。

これを解決するために手伝ってください。

+ (ControlsView *)addArticleControlsToView:(UIView *)view bellowSubview:(UIView *)subview{ 
    ControlsView *articleControls = [[[NSBundle mainBundle] loadNibNamed:@"ControlsView" owner:self options:nil]firstObject]; 
    [view insertSubview:articleControls belowSubview:subview]; 
    NSDictionary *viewsDict = @{@"currentView":articleControls}; 
    [articleControls setTranslatesAutoresizingMaskIntoConstraints:NO]; 
    NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"H:|-0-[currentView]-0-|"] options:0 metrics:@{} views:viewsDict]; 
    NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[currentView(189)]-0-|" options:0 metrics:@{} views:viewsDict]; 
    [view addConstraints:horizontalConstraints]; 
    [view addConstraints:verticalConstraints]; 
    [articleControls setBackgroundColor:[UIColor clearColor]]; 
    articleControls.viewBottomConstraint.constant = -189; 
    [articleControls layoutIfNeeded]; 
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:articleControls action:@selector(slideSheetDown)]; 
    [articleControls addGestureRecognizer:tapGesture]; 
    return articleControls; 
} 

- (void)slideSheetUp { 
    [UIView animateWithDuration:0.5 animations:^{ 
     self.viewBottomConstraint.constant = 0; 
     self.scrollViewBottomConstraint.constant = 189; 
     [self setBackgroundColor:[UIColor clearColor]]; 
     [self.scrollView.superview layoutIfNeeded]; 
     [self layoutIfNeeded]; 
    }]; 
} 

enter image description here

+0

アニメーションブロックの制約定数を更新しないでください。 – Desdenova

+0

@Desdenovaが削除され、動作していますが、iOS 10でこれを現在アニメーション化する方法はありますか? –

+0

'layoutIfNeeded'ビットをブロックに入れてください。その中に定数を設定しないでください。 – Desdenova

答えて

1

ただ、このコードを使用し

- (void)slideSheetUp { 
    self.viewBottomConstraint.constant = 0; 
    self.scrollViewBottomConstraint.constant = 189; 
    [self setBackgroundColor:[UIColor clearColor]]; 
    [UIView animateWithDuration:0.5 animations:^{ 
     [self.scrollView.superview layoutIfNeeded]; 
     [self layoutIfNeeded]; 
    }]; 
} 

それはあなたのために働くことを願っています。 ;)

ハッピーコーディング!

+0

このコードは機能しません。 –

+0

何が起こったか、以前と同じ結果か変更? –

+0

これは以前と同じ結果です。 –

0

私のために働きます。

-(void)hideShowTimerButton:(BOOL)show{ 

[UIView animateWithDuration:0.3 animations:^{ 
    CGRect yourViewFrame = yourView.frame; 
    if(show){ 
     timeContainerViewFrame.origin.y = self.view.frame.size.height; 
    }else{ 
     timeContainerViewFrame.origin.y = self.view.frame.size.height - yourViewFrame.size.height; 
    } 
    yourView.frame = yourViewFrame; 
} completion:^(BOOL finished) { 
}]; 

} 
0

私のビューのアニメーションに影響を与えていない以下のようなコードを再配置して、問題を解決してください。みんなありがとう。

- (void)slideSheetUp { 
    self.viewBottomConstraint.constant = 0; 
    [self setBackgroundColor:[UIColor clearColor]]; 
    [UIView animateWithDuration:0.5 animations:^{ 
     [self layoutIfNeeded]; 
    } completion:^(BOOL finished) { 
     self.scrollViewBottomConstraint.constant = 189; 
     [self.scrollView.superview layoutIfNeeded]; 
    }]; 
} 
関連する問題