diff --git a/Sources/Edit/ZLEditImageViewController.swift b/Sources/Edit/ZLEditImageViewController.swift index 5ff9dc2e..ce8c1012 100644 --- a/Sources/Edit/ZLEditImageViewController.swift +++ b/Sources/Edit/ZLEditImageViewController.swift @@ -1120,7 +1120,7 @@ open class ZLEditImageViewController: UIViewController { angle: currentClipStatus.angle, editRect: currentClipStatus.editRect, isCircle: currentClipStatus.ratio?.isCircle ?? false - ) ?? resImage + ) editModel = ZLEditImageModel( drawPaths: drawPaths, mosaicPaths: mosaicPaths, diff --git a/Sources/General/ZLPhotoPreviewController.swift b/Sources/General/ZLPhotoPreviewController.swift index 87c4a89f..07bb8228 100644 --- a/Sources/General/ZLPhotoPreviewController.swift +++ b/Sources/General/ZLPhotoPreviewController.swift @@ -487,7 +487,6 @@ class ZLPhotoPreviewController: UIViewController { } let config = ZLPhotoConfiguration.default() - let uiConfig = ZLPhotoUIConfiguration.default() let currentModel = arrDataSources[currentIndex] if (!config.allowMixSelect && currentModel.type == .video) || diff --git a/Sources/General/ZLWeakProxy.swift b/Sources/General/ZLWeakProxy.h similarity index 65% rename from Sources/General/ZLWeakProxy.swift rename to Sources/General/ZLWeakProxy.h index f78d31d2..5a636864 100644 --- a/Sources/General/ZLWeakProxy.swift +++ b/Sources/General/ZLWeakProxy.h @@ -1,8 +1,8 @@ // -// ZLWeakProxy.swift +// ZLWeakProxy.h // ZLPhotoBrowser // -// Created by long on 2021/3/10. +// Created by long on 2023/12/5. // // Copyright (c) 2020 Long Zhang <495181165@qq.com> // @@ -24,25 +24,17 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -import UIKit +#import -class ZLWeakProxy: NSObject { - private weak var target: NSObjectProtocol? - - init(target: NSObjectProtocol) { - self.target = target - super.init() - } - - class func proxy(withTarget target: NSObjectProtocol) -> ZLWeakProxy { - return ZLWeakProxy(target: target) - } - - override func forwardingTarget(for aSelector: Selector!) -> Any? { - return target - } - - override func responds(to aSelector: Selector!) -> Bool { - return target?.responds(to: aSelector) ?? false - } -} +NS_ASSUME_NONNULL_BEGIN + +@interface ZLWeakProxy : NSObject + +@property (nonatomic, weak, readonly, nullable) id target; + +- (nonnull instancetype)initWithTarget:(nonnull id)target NS_SWIFT_NAME(init(target:)); ++ (nonnull instancetype)proxyWithTarget:(nonnull id)target NS_SWIFT_NAME(proxy(target:)); + +@end + +NS_ASSUME_NONNULL_END diff --git a/Sources/General/ZLWeakProxy.m b/Sources/General/ZLWeakProxy.m new file mode 100644 index 00000000..55ab2e3c --- /dev/null +++ b/Sources/General/ZLWeakProxy.m @@ -0,0 +1,53 @@ +// +// ZLWeakProxy.m +// ZLPhotoBrowser +// +// Created by long on 2023/12/5. +// +// Copyright (c) 2020 Long Zhang <495181165@qq.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "ZLWeakProxy.h" + +@implementation ZLWeakProxy + +- (instancetype)initWithTarget:(id)target { + _target = target; + return self; +} + ++ (instancetype)proxyWithTarget:(id)target { + return [[ZLWeakProxy alloc] initWithTarget:target]; +} + +- (id)forwardingTargetForSelector:(SEL)selector { + return _target; +} + +- (void)forwardInvocation:(NSInvocation *)invocation { + void *null = NULL; + [invocation setReturnValue:&null]; +} + +- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector { + return [NSObject instanceMethodSignatureForSelector:@selector(init)]; +} + +@end diff --git a/Sources/ZLPhotoBrowser.h b/Sources/ZLPhotoBrowser.h index 6ef83c32..765a4234 100644 --- a/Sources/ZLPhotoBrowser.h +++ b/Sources/ZLPhotoBrowser.h @@ -25,6 +25,7 @@ // THE SOFTWARE. #import +#import //! Project version number for ZLPhotoBrowser. FOUNDATION_EXPORT double ZLPhotoBrowserVersionNumber; @@ -33,5 +34,3 @@ FOUNDATION_EXPORT double ZLPhotoBrowserVersionNumber; FOUNDATION_EXPORT const unsigned char ZLPhotoBrowserVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import - - diff --git a/ZLPhotoBrowser.podspec b/ZLPhotoBrowser.podspec index 496e919f..c59cdf29 100644 --- a/ZLPhotoBrowser.podspec +++ b/ZLPhotoBrowser.podspec @@ -29,7 +29,7 @@ Pod::Spec.new do |s| s.resources = 'Sources/*.{png,bundle}' s.subspec "Core" do |sp| - sp.source_files = ["Sources/**/*.swift", "Sources/ZLPhotoBrowser.h"] + sp.source_files = ["Sources/**/*.{swift,h,m}", "Sources/ZLPhotoBrowser.h"] end end diff --git a/ZLPhotoBrowser.xcodeproj/project.pbxproj b/ZLPhotoBrowser.xcodeproj/project.pbxproj index 1d7b66c6..4c796fc6 100644 --- a/ZLPhotoBrowser.xcodeproj/project.pbxproj +++ b/ZLPhotoBrowser.xcodeproj/project.pbxproj @@ -30,7 +30,6 @@ E466804724FB76C50011E332 /* ZLEditVideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E466804624FB76C50011E332 /* ZLEditVideoViewController.swift */; }; E46EA7D824F79F1C00033853 /* ZLClipImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E46EA7D724F79F1C00033853 /* ZLClipImageViewController.swift */; }; E4765DFB25415F87007B2C0F /* ZLImagePreviewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4765DFA25415F87007B2C0F /* ZLImagePreviewController.swift */; }; - E48CE1C525F89EC900D31452 /* ZLWeakProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E48CE1C425F89EC900D31452 /* ZLWeakProxy.swift */; }; E48E52D52507297500619AED /* ZLClipImageDismissAnimatedTransition.swift in Sources */ = {isa = PBXBuildFile; fileRef = E48E52D42507297500619AED /* ZLClipImageDismissAnimatedTransition.swift */; }; E492ABEB24E53575005E1BD5 /* Cell+ZLPhotoBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = E492ABEA24E53575005E1BD5 /* Cell+ZLPhotoBrowser.swift */; }; E492ABED24E5454E005E1BD5 /* ZLProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E492ABEC24E5454E005E1BD5 /* ZLProgressView.swift */; }; @@ -73,6 +72,8 @@ FDB34268280E6566008F20B3 /* ZLPhotoUIConfiguration+Chaining.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDB34267280E6566008F20B3 /* ZLPhotoUIConfiguration+Chaining.swift */; }; FDC6B5FD273B6E1C00973E43 /* ZLCameraConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDC6B5FC273B6E1C00973E43 /* ZLCameraConfiguration.swift */; }; FDC8ED0B2B0F4032002EB8B9 /* UIGraphicsImageRenderer+ZLPhotoBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDC8ED0A2B0F4032002EB8B9 /* UIGraphicsImageRenderer+ZLPhotoBrowser.swift */; }; + FDCBAFA02B1ED0A9000860FD /* ZLWeakProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = FDCBAF9E2B1ED0A9000860FD /* ZLWeakProxy.m */; }; + FDCBAFA12B1ED0A9000860FD /* ZLWeakProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = FDCBAF9F2B1ED0A9000860FD /* ZLWeakProxy.h */; settings = {ATTRIBUTES = (Public, ); }; }; FDE1DB76289A4B120003CA4D /* NSError+ZLPhotoBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDE1DB75289A4B120003CA4D /* NSError+ZLPhotoBrowser.swift */; }; FDE374252AC1AE3700BA7DA0 /* ZLPaths.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDE374242AC1AE3700BA7DA0 /* ZLPaths.swift */; }; FDF7790B2AC1700F00001015 /* ZLEditorManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDF7790A2AC1700F00001015 /* ZLEditorManager.swift */; }; @@ -102,7 +103,6 @@ E466804624FB76C50011E332 /* ZLEditVideoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLEditVideoViewController.swift; sourceTree = ""; }; E46EA7D724F79F1C00033853 /* ZLClipImageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLClipImageViewController.swift; sourceTree = ""; }; E4765DFA25415F87007B2C0F /* ZLImagePreviewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLImagePreviewController.swift; sourceTree = ""; }; - E48CE1C425F89EC900D31452 /* ZLWeakProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLWeakProxy.swift; sourceTree = ""; }; E48E52D42507297500619AED /* ZLClipImageDismissAnimatedTransition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLClipImageDismissAnimatedTransition.swift; sourceTree = ""; }; E492ABEA24E53575005E1BD5 /* Cell+ZLPhotoBrowser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Cell+ZLPhotoBrowser.swift"; sourceTree = ""; }; E492ABEC24E5454E005E1BD5 /* ZLProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLProgressView.swift; sourceTree = ""; }; @@ -147,6 +147,8 @@ FDB34267280E6566008F20B3 /* ZLPhotoUIConfiguration+Chaining.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ZLPhotoUIConfiguration+Chaining.swift"; sourceTree = ""; }; FDC6B5FC273B6E1C00973E43 /* ZLCameraConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLCameraConfiguration.swift; sourceTree = ""; }; FDC8ED0A2B0F4032002EB8B9 /* UIGraphicsImageRenderer+ZLPhotoBrowser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIGraphicsImageRenderer+ZLPhotoBrowser.swift"; sourceTree = ""; }; + FDCBAF9E2B1ED0A9000860FD /* ZLWeakProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZLWeakProxy.m; sourceTree = ""; }; + FDCBAF9F2B1ED0A9000860FD /* ZLWeakProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZLWeakProxy.h; sourceTree = ""; }; FDE1DB75289A4B120003CA4D /* NSError+ZLPhotoBrowser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSError+ZLPhotoBrowser.swift"; sourceTree = ""; }; FDE374242AC1AE3700BA7DA0 /* ZLPaths.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLPaths.swift; sourceTree = ""; }; FDF7790A2AC1700F00001015 /* ZLEditorManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZLEditorManager.swift; sourceTree = ""; }; @@ -272,7 +274,8 @@ E40ECF4724FFB8BB00A4D923 /* ZLPhotoBrowser.swift */, FD8FEA6628C8B9B60041374B /* ZLResultModel.swift */, FDAE00A8297134C100EE9486 /* ZLAnimationUtils.swift */, - E48CE1C425F89EC900D31452 /* ZLWeakProxy.swift */, + FDCBAF9F2B1ED0A9000860FD /* ZLWeakProxy.h */, + FDCBAF9E2B1ED0A9000860FD /* ZLWeakProxy.m */, ); path = General; sourceTree = ""; @@ -313,6 +316,7 @@ buildActionMask = 2147483647; files = ( E4C911C524E284B30061DA40 /* ZLPhotoBrowser.h in Headers */, + FDCBAFA12B1ED0A9000860FD /* ZLWeakProxy.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -347,7 +351,7 @@ TargetAttributes = { E4C911BF24E284B30061DA40 = { CreatedOnToolsVersion = 12.0; - LastSwiftMigration = 1210; + LastSwiftMigration = 1500; }; }; }; @@ -388,7 +392,6 @@ E4A9CE012505DB91003201C1 /* ZLEmbedAlbumListView.swift in Sources */, E48E52D52507297500619AED /* ZLClipImageDismissAnimatedTransition.swift in Sources */, FD5230B5281562DD0034B782 /* ZLEnlargeButton.swift in Sources */, - E48CE1C525F89EC900D31452 /* ZLWeakProxy.swift in Sources */, E4C911D224E2884E0061DA40 /* ZLPhotoPreviewSheet.swift in Sources */, E46EA7D824F79F1C00033853 /* ZLClipImageViewController.swift in Sources */, E4C911E024E2ACE20061DA40 /* ZLPhotoManager.swift in Sources */, @@ -426,6 +429,7 @@ FDAE00A9297134C100EE9486 /* ZLAnimationUtils.swift in Sources */, FD4C971B29F11918000249BF /* ZLCollectionViewFlowLayout.swift in Sources */, E49BD1FB24E3D515005D7DFB /* Bundle+ZLPhotoBrowser.swift in Sources */, + FDCBAFA02B1ED0A9000860FD /* ZLWeakProxy.m in Sources */, FD201F3F286C7D9B005C6B53 /* ZLCustomAlertProtocol.swift in Sources */, E4D046F02500A341000BAEC2 /* ZLPhotoPreviewAnimatedTransition.swift in Sources */, FDB34268280E6566008F20B3 /* ZLPhotoUIConfiguration+Chaining.swift in Sources */,