Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

某些图片下,在双击图片后,图片被放大,但是图片宽度为屏幕宽度,导致比例失调 #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9973FAAD1A824A1E0089A512"
BuildableName = "SDPhotoBrowser.app"
BlueprintName = "SDPhotoBrowser"
ReferencedContainer = "container:SDPhotoBrowser.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9973FACE1A824A1F0089A512"
BuildableName = "SDPhotoBrowserTests.xctest"
BlueprintName = "SDPhotoBrowserTests"
ReferencedContainer = "container:SDPhotoBrowser.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9973FAAD1A824A1E0089A512"
BuildableName = "SDPhotoBrowser.app"
BlueprintName = "SDPhotoBrowser"
ReferencedContainer = "container:SDPhotoBrowser.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9973FAAD1A824A1E0089A512"
BuildableName = "SDPhotoBrowser.app"
BlueprintName = "SDPhotoBrowser"
ReferencedContainer = "container:SDPhotoBrowser.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9973FAAD1A824A1E0089A512"
BuildableName = "SDPhotoBrowser.app"
BlueprintName = "SDPhotoBrowser"
ReferencedContainer = "container:SDPhotoBrowser.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SDPhotoBrowser.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>9973FAAD1A824A1E0089A512</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>9973FACE1A824A1F0089A512</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
6 changes: 4 additions & 2 deletions SDPhotoBrowser/SDPhotoBrowser/SDBrowserImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,14 @@ - (void)prepareForImageViewScaling
UIImageView *zoomingImageView = [[UIImageView alloc] initWithImage:self.image];
CGSize imageSize = zoomingImageView.image.size;
CGFloat imageViewH = self.bounds.size.height;
CGFloat imageViewW = self.bounds.size.width; //1. 获取图片宽度
if (imageSize.width > 0) {
imageViewH = self.bounds.size.width * (imageSize.height / imageSize.width);
imageViewW = imageViewH / imageSize.height * imageSize.width;
}
zoomingImageView.bounds = CGRectMake(0, 0, self.bounds.size.width, imageViewH);
zoomingImageView.bounds = CGRectMake(0, 0, imageViewW, imageViewH); //2. 设置图片的宽度,而不是显示在 imageView 中.
zoomingImageView.center = _zoomingScroolView.center;
zoomingImageView.contentMode = UIViewContentModeScaleAspectFit;
zoomingImageView.contentMode = UIViewContentModeScaleToFill; //3. 修复缩放后会比例失调的问题
_zoomingImageView = zoomingImageView;
[_zoomingScroolView addSubview:zoomingImageView];
[self addSubview:_zoomingScroolView];
Expand Down