Skip to content

Commit

Permalink
Merge pull request #148 from mlch911/fix-ipad
Browse files Browse the repository at this point in the history
Fix: iPad Resize Window
  • Loading branch information
HeathWang committed May 13, 2024
2 parents f315134 + f8361f0 commit fa7e029
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 18 deletions.
9 changes: 8 additions & 1 deletion Demo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,19 @@
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<false/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
Expand Down
8 changes: 4 additions & 4 deletions HWPanModal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-SwiftDemo/Pods-SwiftDemo-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/HWPanModal-iOS10.0/HWPanModal.framework",
"${BUILT_PRODUCTS_DIR}/HWPanModal/HWPanModal.framework",
"${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -975,7 +975,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-HWPanModalDemo/Pods-HWPanModalDemo-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/HWPanModal-iOS8.0/HWPanModal.framework",
"${BUILT_PRODUCTS_DIR}/HWPanModal/HWPanModal.framework",
"${BUILT_PRODUCTS_DIR}/MJRefresh/MJRefresh.framework",
"${BUILT_PRODUCTS_DIR}/Masonry/Masonry.framework",
);
Expand Down Expand Up @@ -1341,7 +1341,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = K4R83Q5KV5;
INFOPLIST_FILE = "$(SRCROOT)/Demo/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.heath.wang.HWPanModalDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1359,7 +1359,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = K4R83Q5KV5;
INFOPLIST_FILE = "$(SRCROOT)/Demo/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.heath.wang.HWPanModalDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
12 changes: 10 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ use_frameworks!
inhibit_all_warnings!

target 'HWPanModalDemo' do
platform :ios, '8.0'
platform :ios, '11.0'
pod 'Masonry'
pod 'MJRefresh'
pod 'HWPanModal', :path => './'
end

target 'SwiftDemo' do
platform :ios, '10.0'
platform :ios, '11.0'
pod 'SnapKit', '~> 5.0.0'
pod 'HWPanModal', :path => './'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = "11.0"
end
end
end
6 changes: 3 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- HWPanModal (0.9.7)
- HWPanModal (0.9.8)
- Masonry (1.1.0)
- MJRefresh (3.5.0)
- SnapKit (5.0.1)
Expand All @@ -21,11 +21,11 @@ EXTERNAL SOURCES:
:path: "./"

SPEC CHECKSUMS:
HWPanModal: 2340d953661dbeadd1f041cde9e059c0704c873a
HWPanModal: 6951685ca7bdf147ff8a68e7d93d61f08a06dead
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
MJRefresh: 6afc955813966afb08305477dd7a0d9ad5e79a16
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb

PODFILE CHECKSUM: 3046bfffa65a16097d4e0ee1bb220fa9859f7067
PODFILE CHECKSUM: 1c9e6698fa3248dfb5a8e1596a59962a50580f41

COCOAPODS: 1.11.3
37 changes: 30 additions & 7 deletions Sources/View/PanModal/HWPanModalContainerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,25 @@ - (void)prepare {
}
}

- (void)willMoveToSuperview:(UIView *)newSuperview {
[super willMoveToSuperview:newSuperview];
if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
[self.superview removeObserver:self forKeyPath:@"frame"];
[newSuperview addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];
}
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (object == self.presentingView && [keyPath isEqualToString:@"frame"]) {
self.frame = self.presentingView.bounds;
[self setNeedsLayoutUpdate];
[self updateDragIndicatorViewFrame];
[self.contentView hw_panModalTransitionTo:self.contentView.hw_presentationState animated:NO];
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}

- (void)presentAnimationWillBegin {
[[self presentable] panModalTransitionWillBegin];
[self layoutBackgroundView];
Expand Down Expand Up @@ -251,31 +270,35 @@ - (void)adjustPanContainerBackgroundColor {

- (void)updateDragIndicatorView {
if ([self.presentable showDragIndicator]) {
[self addDragIndicatorViewToView:self.panContainerView];
[self addDragIndicatorView];
} else {
self.dragIndicatorView.hidden = YES;
}
}

- (void)addDragIndicatorViewToView:(UIView *)view {
- (void)addDragIndicatorView {
// if has been add, won't update it.
self.dragIndicatorView.hidden = NO;

if (self.dragIndicatorView.superview == view) {
if (self.dragIndicatorView.superview == self.panContainerView) {
[self updateDragIndicatorViewFrame];
[self.dragIndicatorView didChangeToState:HWIndicatorStateNormal];
return;
}

self.handler.dragIndicatorView = self.dragIndicatorView;
[view addSubview:self.dragIndicatorView];
CGSize indicatorSize = [self.dragIndicatorView indicatorSize];

self.dragIndicatorView.frame = CGRectMake((view.hw_width - indicatorSize.width) / 2, -kIndicatorYOffset - indicatorSize.height, indicatorSize.width, indicatorSize.height);
[self.panContainerView addSubview:self.dragIndicatorView];
[self updateDragIndicatorViewFrame];

[self.dragIndicatorView setupSubviews];
[self.dragIndicatorView didChangeToState:HWIndicatorStateNormal];
}

- (void)updateDragIndicatorViewFrame {
CGSize indicatorSize = [self.dragIndicatorView indicatorSize];
self.dragIndicatorView.frame = CGRectMake((self.panContainerView.hw_width - indicatorSize.width) / 2, -kIndicatorYOffset - indicatorSize.height, indicatorSize.width, indicatorSize.height);
}

- (void)updateContainerViewShadow {
HWPanModalShadow *shadow = [[self presentable] contentShadow];
if (shadow.shadowColor) {
Expand Down
2 changes: 1 addition & 1 deletion SwiftDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<false/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down

0 comments on commit fa7e029

Please sign in to comment.