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

修复QMUIToastView设置Frame时可能会循环调用的问题 #1212

Open
wants to merge 7 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
9 changes: 7 additions & 2 deletions QMUIKit/QMUIComponents/ToastView/QMUIToastView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion QMUIKit/QMUICore/QMUIHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
#import <math.h>
#import <sys/utsname.h>

@interface _QMUIFixIssue1263ViewController : UIViewController

@end

@implementation _QMUIFixIssue1263ViewController

- (BOOL)shouldAutorotate {
return NO;
}

@end

const CGPoint QMUIBadgeInvalidateOffset = {-1000, -1000};
NSString *const kQMUIResourcesBundleName = @"QMUIResources";

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions QMUIKit/UIKitExtensions/UISearchBar+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down