Skip to content

Commit

Permalink
4.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
molicechen committed Sep 21, 2024
1 parent 5e47c3b commit 4dca234
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 29 deletions.
5 changes: 5 additions & 0 deletions QMUIKit/QMUICore/QMUICommonDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
#define IOS17_SDK_ALLOWED YES
#endif

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000
/// 当前编译使用的 Base SDK 版本为 iOS 18.0 及以上
#define IOS18_SDK_ALLOWED YES
#endif

#pragma mark - Clang

#define ArgumentToString(macro) #macro
Expand Down
8 changes: 8 additions & 0 deletions QMUIKit/QMUICore/QMUIHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ NS_ASSUME_NONNULL_BEGIN
/// @NEW_DEVICE_CHECKER
@property(class, nonatomic, readonly) BOOL isRegularScreen;

/// iPhone 16 Pro Max
@property(class, nonatomic, readonly) BOOL is69InchScreen;

/// iPhone 14 Pro Max
@property(class, nonatomic, readonly) BOOL is67InchScreenAndiPhone14Later;

Expand All @@ -172,6 +175,9 @@ NS_ASSUME_NONNULL_BEGIN
/// iPhone XS Max / 11 Pro Max
@property(class, nonatomic, readonly) BOOL is65InchScreen;

/// iPhone 16 Pro
@property(class, nonatomic, readonly) BOOL is63InchScreen;

/// iPhone 12 / 12 Pro
@property(class, nonatomic, readonly) BOOL is61InchScreenAndiPhone12Later;

Expand Down Expand Up @@ -199,9 +205,11 @@ NS_ASSUME_NONNULL_BEGIN
/// iPhone 4
@property(class, nonatomic, readonly) BOOL is35InchScreen;

@property(class, nonatomic, readonly) CGSize screenSizeFor69Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor67InchAndiPhone14Later;
@property(class, nonatomic, readonly) CGSize screenSizeFor67Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor65Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor63Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor61InchAndiPhone14ProLater;
@property(class, nonatomic, readonly) CGSize screenSizeFor61InchAndiPhone12Later;
@property(class, nonatomic, readonly) CGSize screenSizeFor61Inch;
Expand Down
131 changes: 104 additions & 27 deletions QMUIKit/QMUICore/QMUIHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "NSString+QMUI.h"
#import "UIInterface+QMUI.h"
#import "NSObject+QMUI.h"
#import "NSArray+QMUI.h"
#import <AVFoundation/AVFoundation.h>
#import <math.h>
#import <sys/utsname.h>
Expand Down Expand Up @@ -317,6 +318,10 @@ + (NSString *)deviceName {
@"iPhone15,5" : @"iPhone 15 Plus",
@"iPhone16,1" : @"iPhone 15 Pro",
@"iPhone16,2" : @"iPhone 15 Pro Max",
@"iPhone17,1" : @"iPhone 16 Pro",
@"iPhone17,2" : @"iPhone 16 Pro Max",
@"iPhone17,3" : @"iPhone 16",
@"iPhone17,4" : @"iPhone 16 Plus",

@"iPad1,1" : @"iPad 1",
@"iPad2,1" : @"iPad 2 (WiFi)",
Expand Down Expand Up @@ -389,6 +394,18 @@ + (NSString *)deviceName {
@"iPad13,11" : @"iPad Pro (12.9 inch, 5th generation)",
@"iPad14,1" : @"iPad mini (6th generation)",
@"iPad14,2" : @"iPad mini (6th generation)",
@"iPad14,3" : @"iPad Pro 11 inch 4th Gen",
@"iPad14,4" : @"iPad Pro 11 inch 4th Gen",
@"iPad14,5" : @"iPad Pro 12.9 inch 6th Gen",
@"iPad14,6" : @"iPad Pro 12.9 inch 6th Gen",
@"iPad14,8" : @"iPad Air 6th Gen",
@"iPad14,9" : @"iPad Air 6th Gen",
@"iPad14,10" : @"iPad Air 7th Gen",
@"iPad14,11" : @"iPad Air 7th Gen",
@"iPad16,3" : @"iPad Pro 11 inch 5th Gen",
@"iPad16,4" : @"iPad Pro 11 inch 5th Gen",
@"iPad16,5" : @"iPad Pro 12.9 inch 7th Gen",
@"iPad16,6" : @"iPad Pro 12.9 inch 7th Gen",

@"iPod1,1" : @"iPod touch 1",
@"iPod2,1" : @"iPod touch 2",
Expand Down Expand Up @@ -440,6 +457,11 @@ + (NSString *)deviceName {
@"Watch6,16" : @"Apple Watch Series 8 41mm case (GPS+Cellular)",
@"Watch6,17" : @"Apple Watch Series 8 45mm case (GPS+Cellular)",
@"Watch6,18" : @"Apple Watch Ultra",
@"Watch7,1" : @"Apple Watch Series 9 41mm case (GPS)",
@"Watch7,2" : @"Apple Watch Series 9 45mm case (GPS)",
@"Watch7,3" : @"Apple Watch Series 9 41mm case (GPS+Cellular)",
@"Watch7,4" : @"Apple Watch Series 9 45mm case (GPS+Cellular)",
@"Watch7,5" : @"Apple Watch Ultra 2",

@"AudioAccessory1,1" : @"HomePod",
@"AudioAccessory1,2" : @"HomePod",
Expand Down Expand Up @@ -542,9 +564,26 @@ + (BOOL)isNotchedScreen {
}

+ (BOOL)isRegularScreen {
if ([@[
@"iPhone 14 Pro",
@"iPhone 15",
@"iPhone 16",
] qmui_firstMatchWithBlock:^BOOL(NSString *item) {
return [QMUIHelper.deviceName hasPrefix:item];
}]) {
return YES;
}
return [self isIPad] || (!IS_ZOOMEDMODE && ([self is67InchScreenAndiPhone14Later] || [self is67InchScreen] || [self is65InchScreen] || [self is61InchScreen] || [self is55InchScreen]));
}

static NSInteger is69InchScreen = -1;
+ (BOOL)is69InchScreen {
if (is69InchScreen < 0) {
is69InchScreen = CGSizeEqualToSize(CGSizeMake(DEVICE_WIDTH, DEVICE_HEIGHT), self.screenSizeFor69Inch) ? 1 : 0;
}
return is69InchScreen > 0;
}

static NSInteger is67InchScreenAndiPhone14Later = -1;
+ (BOOL)is67InchScreenAndiPhone14Later {
if (is67InchScreenAndiPhone14Later < 0) {
Expand All @@ -571,6 +610,14 @@ + (BOOL)is65InchScreen {
return is65InchScreen > 0;
}

static NSInteger is63InchScreen = -1;
+ (BOOL)is63InchScreen {
if (is63InchScreen < 0) {
is63InchScreen = CGSizeEqualToSize(CGSizeMake(DEVICE_WIDTH, DEVICE_HEIGHT), self.screenSizeFor63Inch) ? 1 : 0;
}
return is63InchScreen > 0;
}

static NSInteger is61InchScreenAndiPhone14ProLater = -1;
+ (BOOL)is61InchScreenAndiPhone14ProLater {
if (is61InchScreenAndiPhone14ProLater < 0) {
Expand Down Expand Up @@ -645,6 +692,10 @@ + (BOOL)is35InchScreen {
return is35InchScreen > 0;
}

+ (CGSize)screenSizeFor69Inch {
return CGSizeMake(440, 956);
}

+ (CGSize)screenSizeFor67InchAndiPhone14Later {
return CGSizeMake(430, 932);// iPhone 14 Pro Max
}
Expand All @@ -665,6 +716,10 @@ + (CGSize)screenSizeFor61InchAndiPhone12Later {
return CGSizeMake(390, 844);
}

+ (CGSize)screenSizeFor63Inch {
return CGSizeMake(402, 874);
}

+ (CGSize)screenSizeFor61Inch {
return CGSizeMake(414, 896);
}
Expand Down Expand Up @@ -724,6 +779,26 @@ + (UIEdgeInsets)safeAreaInsetsForDeviceWithNotch {
static NSDictionary<NSString *, NSDictionary<NSNumber *, NSValue *> *> *dict;
if (!dict) {
dict = @{
// iPhone 16 Pro
@"iPhone17,1": @{
@(UIInterfaceOrientationPortrait): [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(62, 0, 34, 0)],
@(UIInterfaceOrientationLandscapeLeft): [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(0, 62, 21, 62)],
},
// iPhone 16 Pro Max
@"iPhone17,2": @{
@(UIInterfaceOrientationPortrait): [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(62, 0, 34, 0)],
@(UIInterfaceOrientationLandscapeLeft): [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(0, 62, 21, 62)],
},
// iPhone 16
@"iPhone17,3": @{
@(UIInterfaceOrientationPortrait): [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(59, 0, 34, 0)],
@(UIInterfaceOrientationLandscapeLeft): [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(0, 59, 21, 59)],
},
// iPhone 16 Plus
@"iPhone17,4": @{
@(UIInterfaceOrientationPortrait): [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(59, 0, 34, 0)],
@(UIInterfaceOrientationLandscapeLeft): [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(0, 59, 21, 59)],
},
// iPhone 15
@"iPhone15,4": @{
@(UIInterfaceOrientationPortrait): [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(47, 0, 34, 0)],
Expand Down Expand Up @@ -960,19 +1035,16 @@ + (BOOL)isZoomedMode {

+ (BOOL)isDynamicIslandDevice {
if (!IS_IPHONE) return NO;
__block BOOL result = NO;
NSString *deviceName = self.deviceName;
[@[
if ([@[
@"iPhone 14 Pro",
@"iPhone 14 Pro Max",
@"iPhone 15",
] enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([deviceName hasPrefix:obj]) {
result = YES;
*stop = YES;
}
}];
return result;
@"iPhone 16",
] qmui_firstMatchWithBlock:^BOOL(NSString *item) {
return [QMUIHelper.deviceName hasPrefix:item];
}]) {
return YES;
}
return NO;
}

- (void)handleAppSizeWillChange:(NSNotification *)notification {
Expand Down Expand Up @@ -1017,13 +1089,13 @@ + (CGFloat)statusBarHeightConstant {
// iPhone 13 Mini
return 48;
}
if ([deviceModel isEqualToString:@"iPhone15,2"] // iPhone 14 Pro
|| [deviceModel isEqualToString:@"iPhone15,3"] // iPhone 14 Pro Max
|| [deviceModel isEqualToString:@"iPhone15,4"] // iPhone 15
|| [deviceModel isEqualToString:@"iPhone15,5"] // iPhone 15 Plus
|| [deviceModel isEqualToString:@"iPhone16,1"] // iPhone 15 Pro
|| [deviceModel isEqualToString:@"iPhone16,2"] // iPhone 15 Pro Max
) {
if ([@[
@"iPhone 14 Pro",
@"iPhone 15",
@"iPhone 16",
] qmui_firstMatchWithBlock:^BOOL(NSString *item) {
return [QMUIHelper.deviceName hasPrefix:item];
}]) {
return 54;
}
if (IS_61INCH_SCREEN_AND_IPHONE12 || IS_67INCH_SCREEN) {
Expand All @@ -1040,15 +1112,20 @@ + (CGFloat)navigationBarMaxYConstant {
result += PreferredValueForVisualDevice(44, 32);
} else {
result += 44;
NSString *deviceModel = [QMUIHelper deviceModel];
if ([deviceModel isEqualToString:@"iPhone15,2"] // iPhone 14 Pro
|| [deviceModel isEqualToString:@"iPhone15,3"] // iPhone 14 Pro Max
|| [deviceModel isEqualToString:@"iPhone15,4"] // iPhone 15
|| [deviceModel isEqualToString:@"iPhone15,5"] // iPhone 15 Plus
|| [deviceModel isEqualToString:@"iPhone16,1"] // iPhone 15 Pro
|| [deviceModel isEqualToString:@"iPhone16,2"] // iPhone 15 Pro Max
) {
result -= PixelOne;
if ([@[
@"iPhone 16 Pro",
] qmui_firstMatchWithBlock:^BOOL(NSString *item) {
return [QMUIHelper.deviceName hasPrefix:item];
}]) {
result += 2 + PixelOne;// 56.333
} else if ([@[
@"iPhone 14 Pro",
@"iPhone 15",
@"iPhone 16",
] qmui_firstMatchWithBlock:^BOOL(NSString *item) {
return [QMUIHelper.deviceName hasPrefix:item];
}]) {
result -= PixelOne;// 53.667
}
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUICore/QMUIRuntime.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static BOOL strendswith(const char *str, const char *suffix) {
NSString *executablePath = NSBundle.mainBundle.executablePath;
if (!executablePath) return nil;
const headerType *target_image_header = 0;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000
#ifdef IOS18_SDK_ALLOWED
#if DEBUG
// Xcode16之后,优先查找debug.dylib
NSString *debugImagePath = [NSString stringWithFormat:@"%@.debug.dylib", executablePath];
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/UIKitExtensions/UITableView+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ + (void)load {
};
});

// [UIKit Bug] iOS 14 及以下版本,将 UISearchBar 作为 tableHeaderView 使用的 UITableView,如果同时设置了 estimatedRowHeight,则 contentSize 会错乱,导致滚动异常
// [UIKit Bug] 将 UISearchBar 作为 tableHeaderView 使用的 UITableView,如果同时设置了 estimatedRowHeight,则 contentSize 会错乱,导致滚动异常
// https://github.com/Tencent/QMUI_iOS/issues/1161
if (@available(iOS 15.0, *)) {
} else {
Expand Down

0 comments on commit 4dca234

Please sign in to comment.