横竖屏切换时UIScrollView偏移量混乱问题

1.设备横竖屏切换通知

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientChange:) name:UIDeviceOrientationDidChangeNotification object:nil];

- (void)orientationDidChange:(NSNotification *)notification
{
    UIDeviceOrientation  orient = [UIDevice currentDevice].orientation;
    //需要重新设置contentSize,contentOffset
    _collectionView.contentSize = CGSizeMake(_arrPageModel.count * self.view.frame.size.width,self.view.frame.size.height);
    _collectionView.contentOffset = CGPointMake(_currentIndexPath.item * self.view.frame.size.width, 0);
}

你可能感兴趣的:(横竖屏切换时UIScrollView偏移量混乱问题)