Skip to content

Commit 49a6995

Browse files
author
Evgenii Neumerzhitckii
committed
Fix position of small image
1 parent 380bc64 commit 49a6995

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

ImageScroll.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
2B7CB30B18972758009FD635 /* wallabi_small.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2B7CB30A18972758009FD635 /* wallabi_small.jpg */; };
1011
2B97BEFF1748425C0094564B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B97BEFE1748425C0094564B /* UIKit.framework */; };
1112
2B97BF011748425C0094564B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B97BF001748425C0094564B /* Foundation.framework */; };
1213
2B97BF031748425C0094564B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B97BF021748425C0094564B /* CoreGraphics.framework */; };
@@ -22,6 +23,7 @@
2223
/* End PBXBuildFile section */
2324

2425
/* Begin PBXFileReference section */
26+
2B7CB30A18972758009FD635 /* wallabi_small.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = wallabi_small.jpg; sourceTree = "<group>"; };
2527
2B97BEFB1748425C0094564B /* ImageScroll.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageScroll.app; sourceTree = BUILT_PRODUCTS_DIR; };
2628
2B97BEFE1748425C0094564B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
2729
2B97BF001748425C0094564B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -85,6 +87,7 @@
8587
2B97BF041748425C0094564B /* ImageScroll */ = {
8688
isa = PBXGroup;
8789
children = (
90+
2B7CB30A18972758009FD635 /* wallabi_small.jpg */,
8891
2B97BF211748476A0094564B /* wallabi.jpg */,
8992
2B97BF161748425C0094564B /* MainStoryboard.storyboard */,
9093
2B97BF191748425C0094564B /* ImageScrollViewController.h */,
@@ -165,6 +168,7 @@
165168
2B97BF091748425C0094564B /* InfoPlist.strings in Resources */,
166169
2B97BF111748425C0094564B /* Default.png in Resources */,
167170
2B97BF131748425C0094564B /* [email protected] in Resources */,
171+
2B7CB30B18972758009FD635 /* wallabi_small.jpg in Resources */,
168172
2B97BF151748425C0094564B /* [email protected] in Resources */,
169173
2B97BF181748425C0094564B /* MainStoryboard.storyboard in Resources */,
170174
2B97BF221748476A0094564B /* wallabi.jpg in Resources */,

ImageScroll/ImageScrollViewController.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ - (void) viewWillAppear:(BOOL)animated {
3434
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
3535
[super willAnimateRotationToInterfaceOrientation:interfaceOrientation duration:duration];
3636
[self updateZoom];
37+
if (self.scrollView.zoomScale == 1) self.scrollView.zoomScale = 1.0001;
3738
}
3839

3940
- (void) scrollViewDidZoom:(UIScrollView *)scrollView {
@@ -60,14 +61,13 @@ - (void) updateConstraints {
6061
self.constraintBottom.constant = vPadding;
6162
}
6263

63-
6464
- (void) updateZoom {
6565
float minZoom = MIN(self.view.bounds.size.width / self.imageView.image.size.width,
6666
self.view.bounds.size.height / self.imageView.image.size.height);
6767

68-
if (minZoom > 1) return;
68+
if (minZoom > 1) minZoom = 1;
6969

70-
// Prevent excessive zoom out
70+
// Prevent from zooming out too much
7171
self.scrollView.minimumZoomScale = minZoom;
7272

7373
// Zoom to show as much image as possible

ImageScroll/wallabi_small.jpg

13.4 KB
Loading

0 commit comments

Comments
 (0)