Open sandeepsuthar opened 6 years ago
I have the same problem with iOS 11. @sandeepsuthar Have you found a solution?
i found that without caption view everything works fine but with caption this library show two pages at same time. @poprandi
It looks like that in iOS 11 the removeFromSuperview function will call every time viewWillLayoutSubviews. I changed viewWillAppear and viewWillLayoutSubviews for iOS 11:
- (void)viewWillAppear:(BOOL)animated {
// Super
[super viewWillAppear:animated];
// Status bar
if (!_viewHasAppearedInitially) {
_leaveStatusBarAlone = [self presentingViewControllerPrefersStatusBarHidden];
// Check if status bar is hidden on first appear, and if so then ignore it
if (CGRectEqualToRect([[UIApplication sharedApplication] statusBarFrame], CGRectZero)) {
_leaveStatusBarAlone = YES;
}
}
// Set style
if (!_leaveStatusBarAlone && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
_previousStatusBarStyle = [[UIApplication sharedApplication] statusBarStyle];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:animated];
}
// Navigation bar appearance
if (!_viewIsActive && [self.navigationController.viewControllers objectAtIndex:0] != self) {
[self storePreviousNavBarAppearance];
}
[self setNavBarAppearance:animated];
// Update UI
[self hideControlsAfterDelay];
// Initial appearance
if (!_viewHasAppearedInitially) {
if (_startOnGrid) {
[self showGrid:NO];
}
}
// If rotation occured while we're presenting a modal
// and the index changed, make sure we show the right one now
if (_currentPageIndex != _pageIndexBeforeRotation) {
[self jumpToPageAtIndex:_pageIndexBeforeRotation animated:NO];
}
// Layout
if (@available(iOS 11.0, *)) {
[self layoutVisiblePages];
}
[self.view setNeedsLayout];
}
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
if (@available(iOS 11.0, *)) {
// do nothing
} else {
[self layoutVisiblePages];
}
}
@sandeepsuthar
Thank you so much for your valuable and quick response. You saved my hours but what's wrong with iOS 11? Thank you again @poprandi
@poprandi When we delete any image then scrollview show black shadow with your logic. Rest working fine on iOS 11. How can i solve this?
@poprandi Black shadow with image delete issue has been solved but when zoom photo bigger then screen size and then single click on it. Top bar and Bottom bar will toggle then suddenly image zoom shifted downward/upward slightly. how to overcome this problem in iOS 11?
Fixed another iOS 11 issue in #622
It looks like that in iOS 11 the removeFromSuperview addSubview function will call every time viewWillLayoutSubviews.
在self.view中添加View(addSubview)或者移除View(removeFromSuperview)都会触发viewWillLayoutSubviews方法,我的做法是判断当前_gridController == nil 如果_gridController == nil 那么设置 _pagingScrollView 显示在可见范围,否则显示在不可见范围,修改方法 layoutVisiblePages
将下面这几行替换
// Get paging scroll view frame to determine if anything needs changing
CGRect pagingScrollViewFrame = [self frameForPagingScrollView];
// Frame needs changing
if (!_skipNextPagingScrollViewPositioning) {
_pagingScrollView.frame = pagingScrollViewFrame;
}
_skipNextPagingScrollViewPositioning = NO;
替换为
if (_gridController) {
CGRect newPagingFrame = [self frameForPagingScrollView];
newPagingFrame = CGRectOffset(newPagingFrame, 0, (self.startOnGrid ? 1 : -1) * newPagingFrame.size.height);
_pagingScrollView.frame = newPagingFrame;
} else {
// Get paging scroll view frame to determine if anything needs changing
CGRect pagingScrollViewFrame = [self frameForPagingScrollView];
_pagingScrollView.frame = pagingScrollViewFrame;
}
when i zoom the image and then toggle the top and bottom bar then zoom also shifted slightly . how to solve this? @toutoumu @yakubbaev
When i use this library for iOS 11 and display multiple images from array then swipe one by one. When 0th index image swipe for next image to display then 1st and 2nd image both show at same time. Below iOS 11 all works well but on iOS 11 it show two images on full screen preview.