-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
CGFloat width = self.scrollView.frame.size.width;
CGFloat Height = self.scrollView.frame.size.height;
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
// self.scrollView.frame = self.view.bounds;
for (NSInteger i = 0; i < self.contentViewAr.count; i++) {
UIView *viewC = self.contentViewAr[i];
viewC.frame = CGRectMake(i * Height, 0, Height, width);
}
self.scrollView.contentSize = CGSizeMake(self.contentViewAr.count * Height, 0);
} completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
if (self.selectIndex>0) {
// self.scrollView.contentOffset = CGPointMake(Height * self.selectIndex, 0);
[self.scrollView setContentOffset:CGPointMake(Height * self.selectIndex, 0) animated:YES];
}
}
if (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) {
// self.scrollView.contentOffset = CGPointMake(Height * self.selectIndex, 0);
[self.scrollView setContentOffset:CGPointMake(Height * self.selectIndex, 0) animated:YES];
}
}];
}
网友评论