diff --git a/QMUIKit/QMUIComponents/ToastView/QMUIToastView.m b/QMUIKit/QMUIComponents/ToastView/QMUIToastView.m index 58a3b3eb..8f1324b0 100644 --- a/QMUIKit/QMUIComponents/ToastView/QMUIToastView.m +++ b/QMUIKit/QMUIComponents/ToastView/QMUIToastView.m @@ -90,6 +90,13 @@ - (void)didMoveToSuperview { if (![kToastViews containsObject:self]) { [kToastViews addObject:self]; } + /// https://github.com/Tencent/QMUI_iOS/issues/1186 + self.translatesAutoresizingMaskIntoConstraints = NO; + NSLayoutConstraint *top = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.superview attribute:NSLayoutAttributeTop multiplier:1 constant:0]; + NSLayoutConstraint *leading = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.superview attribute:NSLayoutAttributeLeading multiplier:1 constant:0]; + NSLayoutConstraint *bottom = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.superview attribute:NSLayoutAttributeBottom multiplier:1 constant:0]; + NSLayoutConstraint *trailing = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.superview attribute:NSLayoutAttributeTrailing multiplier:1 constant:0]; + [self.superview addConstraints:@[top, leading, bottom, trailing]]; } else { // hide if ([kToastViews containsObject:self]) { @@ -143,7 +150,6 @@ - (void)setContentView:(UIView *)contentView { - (void)layoutSubviews { [super layoutSubviews]; - self.frame = self.parentView.bounds; self.maskView.frame = self.bounds; CGFloat contentWidth = CGRectGetWidth(self.parentView.bounds); @@ -328,7 +334,6 @@ + (BOOL)hideAllToastInView:(UIView *)view animated:(BOOL)animated { BOOL result = NO; for (QMUIToastView *toastView in toastViews) { result = YES; - toastView.removeFromSuperViewWhenHide = YES; [toastView hideAnimated:animated]; } return result; diff --git a/QMUIKit/QMUICore/QMUIHelper.m b/QMUIKit/QMUICore/QMUIHelper.m index 24bed4f7..b6a7526f 100644 --- a/QMUIKit/QMUICore/QMUIHelper.m +++ b/QMUIKit/QMUICore/QMUIHelper.m @@ -24,6 +24,18 @@ #import #import +@interface _QMUIFixIssue1263ViewController : UIViewController + +@end + +@implementation _QMUIFixIssue1263ViewController + +- (BOOL)shouldAutorotate { + return NO; +} + +@end + const CGPoint QMUIBadgeInvalidateOffset = {-1000, -1000}; NSString *const kQMUIResourcesBundleName = @"QMUIResources"; @@ -482,7 +494,8 @@ + (BOOL)isNotchedScreen { UIWindow *window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; peripheryInsets = window.safeAreaInsets; if (peripheryInsets.bottom <= 0) { - UIViewController *viewController = [UIViewController new]; + /// https://github.com/Tencent/QMUI_iOS/issues/1263 + _QMUIFixIssue1263ViewController *viewController = [_QMUIFixIssue1263ViewController new]; window.rootViewController = viewController; if (CGRectGetMinY(viewController.view.frame) > 20) { peripheryInsets.bottom = 1; diff --git a/QMUIKit/UIKitExtensions/UISearchBar+QMUI.m b/QMUIKit/UIKitExtensions/UISearchBar+QMUI.m index b6d386d3..391d2e69 100644 --- a/QMUIKit/UIKitExtensions/UISearchBar+QMUI.m +++ b/QMUIKit/UIKitExtensions/UISearchBar+QMUI.m @@ -80,8 +80,8 @@ + (void)load { } else { searchBar = (UISearchBar *)selfObject.superview.superview; } - NSAssert(!searchBar || [searchBar isKindOfClass:UISearchBar.class], @"Can not find UISearchBar from cancelButton"); - if (searchBar.qmui_alwaysEnableCancelButton && !searchBar.qmui_searchController) { + + if ([searchBar isKindOfClass:UISearchBar.class] && searchBar.qmui_alwaysEnableCancelButton && !searchBar.qmui_searchController) { firstArgv = YES; }