Skip to content

Commit 632bc7f

Browse files
薛精豪薛精豪
authored andcommitted
pod 2.4.1
1 parent 293106b commit 632bc7f

4 files changed

Lines changed: 30 additions & 19 deletions

File tree

JHFrameLayout.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = 'JHFrameLayout'
33
s.summary = 'A simple way for frame layout. It can autolayout in version 2.0.'
4-
s.version = '2.4.0'
4+
s.version = '2.4.1'
55
s.license = { :type => 'MIT'}
66
s.authors = { 'Haocold' => 'xjh093@126.com' }
77
s.homepage = 'https://github.com/xjh093/JHFrameLayout'

JHFrameLayout/JHFrameLayoutView.m

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ - (JHLayoutBottomOfView)centerYOffsetBottomOfView{
673673
@interface JHFrameLayoutView()
674674
@property (nonatomic, assign) BOOL initFlag;
675675
@property (nonatomic, assign) BOOL superviewObserveFlag;
676+
@property (nonatomic, unsafe_unretained) UIView *superView;
676677
@end
677678

678679
@implementation JHFrameLayoutView
@@ -689,9 +690,9 @@ - (instancetype)initWithFrame:(CGRect)frame
689690
- (void)dealloc{
690691
[[NSNotificationCenter defaultCenter] removeObserver:self];
691692
if (_superviewObserveFlag) {
692-
[self.superview removeObserver:self forKeyPath:@"frame"];
693-
[self.superview removeObserver:self forKeyPath:@"bounds"];
694-
[self.superview removeObserver:self forKeyPath:@"center"];
693+
[_superView removeObserver:self forKeyPath:@"frame"];
694+
[_superView removeObserver:self forKeyPath:@"bounds"];
695+
[_superView removeObserver:self forKeyPath:@"center"];
695696
}
696697
}
697698

@@ -709,20 +710,30 @@ - (void)jh_initOnce
709710
{
710711
_initFlag = YES;
711712

712-
// JHFrameLayoutView is not UIViewController's root view.
713-
if (![self valueForKey:@"viewDelegate"]) {
714-
715-
// Screen Rotate Notification
716-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jh_delayLayoutSubviews) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
717-
718-
// Observe superview's frame
719-
if (self.superview) {
720-
_superviewObserveFlag = YES;
721-
[self.superview addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];
722-
[self.superview addObserver:self forKeyPath:@"bounds" options:NSKeyValueObservingOptionNew context:nil];
723-
[self.superview addObserver:self forKeyPath:@"center" options:NSKeyValueObservingOptionNew context:nil];
713+
id vc;
714+
UIView *view = self;
715+
while (view != nil) {
716+
vc = [view valueForKey:@"viewDelegate"];
717+
if (vc != nil) {
718+
719+
// JHFrameLayoutView is not UIViewController's root view.
720+
if (![[vc view] isKindOfClass:[JHFrameLayoutView class]]){
721+
722+
// Screen Rotate Notification
723+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jh_delayLayoutSubviews) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
724+
725+
// Observe superview's frame
726+
if (self.superview) {
727+
_superviewObserveFlag = YES;
728+
_superView = self.superview;
729+
[self.superview addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];
730+
[self.superview addObserver:self forKeyPath:@"bounds" options:NSKeyValueObservingOptionNew context:nil];
731+
[self.superview addObserver:self forKeyPath:@"center" options:NSKeyValueObservingOptionNew context:nil];
732+
}
733+
}
734+
break;
724735
}
725-
736+
view = view.superview;
726737
}
727738
}
728739

JHFrameLayout/UIView+JHFrameLayout.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ - (void)jh_bottomIs:(CGFloat)bottom{
179179
}
180180

181181
- (void)jh_bottomIsEqualToView:(UIView *)view{
182-
[self jh_bottomIs:0 fromBottomOfView:view updateHeight:YES];
182+
[self jh_bottomIs:0 fromBottomOfView:view updateHeight:NO];
183183
}
184184

185185
- (void)jh_bottomIs:(CGFloat)offsetY fromBottomOfView:(UIView *)view updateHeight:(BOOL)flag{
@@ -208,7 +208,7 @@ - (void)jh_rightIs:(CGFloat)right{
208208
}
209209

210210
- (void)jh_rightIsEqualToView:(UIView *)view{
211-
[self jh_rightIs:0 fromRightOfView:view updateWidth:YES];
211+
[self jh_rightIs:0 fromRightOfView:view updateWidth:NO];
212212
}
213213

214214
- (void)jh_rightIs:(CGFloat)offsetX fromRightOfView:(UIView *)view updateWidth:(BOOL)flag{

0 commit comments

Comments
 (0)