Skip to content

Commit

Permalink
3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLice committed Apr 19, 2019
1 parent 968519d commit 074a65e
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 13 deletions.
2 changes: 1 addition & 1 deletion QMUIKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.1.4</string>
<string>3.1.5</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ NS_ASSUME_NONNULL_BEGIN
* @param currentImageIndex 当前展示的图片在 imageAssetArray 的索引
* @param singleCheckMode 是否为单选模式,如果是单选模式,则不显示 checkbox
*/
- (void)updateImagePickerPreviewViewWithImagesAssetArray:(NSArray<QMUIAsset *> * _Nullable)imageAssetArray
selectedImageAssetArray:(NSArray<QMUIAsset *> * _Nullable)selectedImageAssetArray
- (void)updateImagePickerPreviewViewWithImagesAssetArray:(NSMutableArray<QMUIAsset *> * _Nullable)imageAssetArray
selectedImageAssetArray:(NSMutableArray<QMUIAsset *> * _Nullable)selectedImageAssetArray
currentImageIndex:(NSInteger)currentImageIndex
singleCheckMode:(BOOL)singleCheckMode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
[self initPreviewViewControllerIfNeeded];
if (!self.allowsMultipleSelection) {
// 单选的情况下
[self.imagePickerPreviewViewController updateImagePickerPreviewViewWithImagesAssetArray:@[imageAsset]
[self.imagePickerPreviewViewController updateImagePickerPreviewViewWithImagesAssetArray:@[imageAsset].mutableCopy
selectedImageAssetArray:nil
currentImageIndex:0
singleCheckMode:YES];
Expand Down
12 changes: 12 additions & 0 deletions QMUIKit/QMUIComponents/QMUITextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,21 @@ - (void)setFrame:(CGRect)frame {
// 如果没走完 didInitialize,说明 self.maximumHeight 尚未被赋初始值 CGFLOAT_MAX,此时的值为 0,就会导致调用 initWithFrame: 时高度无效,必定被指定为 0
frame = CGRectSetHeight(frame, MIN(CGRectGetHeight(frame), self.maximumHeight));
}

// 重写了 UITextView 的 drawRect: 后,对于带小数点的 frame 会导致文本框右边多出一条黑线,原因未明,暂时这样处理
// https://github.com/Tencent/QMUI_iOS/issues/557
frame = CGRectFlatted(frame);

[super setFrame:frame];
}

- (void)setBounds:(CGRect)bounds {
// 重写了 UITextView 的 drawRect: 后,对于带小数点的 frame 会导致文本框右边多出一条黑线,原因未明,暂时这样处理
// https://github.com/Tencent/QMUI_iOS/issues/557
bounds = CGRectFlatted(bounds);
[super setBounds:bounds];
}

- (void)layoutSubviews {
[super layoutSubviews];
if (self.placeholder.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef QMUIKit_h
#define QMUIKit_h

static NSString * const QMUI_VERSION = @"3.1.4";
static NSString * const QMUI_VERSION = @"3.1.5";

#if __has_include("CAAnimation+QMUI.h")
#import "CAAnimation+QMUI.h"
Expand Down
4 changes: 3 additions & 1 deletion QMUIKit/QMUIMainFrame/QMUICommonTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ - (void)initSubviews {

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView qmui_clearsSelection];
if (!self.tableView.allowsMultipleSelection) {
[self.tableView qmui_clearsSelection];
}
}

- (void)viewDidLayoutSubviews {
Expand Down
8 changes: 6 additions & 2 deletions QMUIKit/UIKitExtensions/UILabel+QMUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UILabel (QMUI)

- (instancetype)qmui_initWithFont:(UIFont *)font textColor:(UIColor *)textColor;
- (instancetype)qmui_initWithFont:(nullable UIFont *)font textColor:(nullable UIColor *)textColor;

/**
* @brief 在需要特殊样式时,可通过此属性直接给整个 label 添加 NSAttributeName 系列样式,然后 setText 即可,无需使用繁琐的 attributedText
Expand All @@ -35,7 +37,7 @@
* 唯一例外的极端情况是:先用方法2将文字设成红色,再用方法1将文字设成蓝色,最后再 setText,这时虽然代码执行顺序靠后的是方法1,但最终生效的会是方法2,为了避免这种极端情况的困扰,建议不要同时使用方法1和方法2去设置同一种样式。
*
*/
@property(nonatomic, copy) NSDictionary<NSAttributedStringKey, id> *qmui_textAttributes;
@property(nullable, nonatomic, copy) NSDictionary<NSAttributedStringKey, id> *qmui_textAttributes;

/**
* Setter 设置当前整段文字的行高
Expand Down Expand Up @@ -78,3 +80,5 @@
- (void)qmui_avoidBlendedLayersIfShowingChineseWithBackgroundColor:(UIColor *)color;

@end

NS_ASSUME_NONNULL_END
4 changes: 2 additions & 2 deletions QMUIKit/UIKitExtensions/UILabel+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (void)qmui_setText:(NSString *)text {

// 在 qmui_textAttributes 样式基础上添加用户传入的 attributedString 中包含的新样式。换句话说,如果这个方法里有样式冲突,则以 attributedText 为准
- (void)qmui_setAttributedText:(NSAttributedString *)text {
if (!text) {
if (!text || (!self.qmui_textAttributes.count && ![self _hasSetQmuiLineHeight])) {
[self qmui_setAttributedText:text];
return;
}
Expand Down Expand Up @@ -110,7 +110,7 @@ - (NSDictionary *)qmui_textAttributes {

// 去除最后一个字的 kern 效果,并且在有必要的情况下应用 qmui_setLineHeight: 设置的行高
- (NSAttributedString *)attributedStringWithKernAndLineHeightAdjusted:(NSAttributedString *)string {
if (!string || !string.length) {
if (!string.length) {
return string;
}
NSMutableAttributedString *attributedString = nil;
Expand Down
12 changes: 12 additions & 0 deletions QMUIKit/UIKitExtensions/UITableView+QMUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/// cell 在当前 section 里的位置,注意判断时要用 (var & xxx) == xxx 的方式
typedef NS_OPTIONS(NSInteger, QMUITableViewCellPosition) {
QMUITableViewCellPositionNone = 0, // 默认
Expand Down Expand Up @@ -114,4 +116,14 @@ typedef NS_OPTIONS(NSInteger, QMUITableViewCellPosition) {
*/
- (BOOL)qmui_canScroll;

/**
等同于 UITableView 自 iOS 11 开始新增的同名方法,但兼容 iOS 11 以下的系统使用。
@param updates insert/delete/reload/move calls
@param completion completion callback
*/
- (void)qmui_performBatchUpdates:(void (NS_NOESCAPE ^ _Nullable)(void))updates completion:(void (^ _Nullable)(BOOL finished))completion;

@end

NS_ASSUME_NONNULL_END
14 changes: 14 additions & 0 deletions QMUIKit/UIKitExtensions/UITableView+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

const NSUInteger kFloatValuePrecision = 4;// 统一一个小数点运算精度

@interface UITableView ()

// iOS 9、10 的 UITableView 都有这个私有方法,因此把它显示声明一次以便调用
- (void)_performBatchUpdates:(void (NS_NOESCAPE ^ _Nullable)(void))updates completion:(void (^ _Nullable)(BOOL finished))completion;
@end

@implementation UITableView (QMUI)

+ (void)load {
Expand Down Expand Up @@ -314,4 +320,12 @@ - (void)QMUISymbolicUsingTableViewEstimatedHeightMakeWarning {
QMUILog(@"UITableView 的 estimatedRow(SectionHeader / SectionFooter)Height 属性会影响 contentSize、sizeThatFits:、rectForXxx 等方法的计算,导致计算结果不准确,建议重新考虑是否要使用 estimated。可添加 '%@' 的 Symbolic Breakpoint 以捕捉此类信息\n%@", NSStringFromSelector(_cmd), [NSThread callStackSymbols]);
}

- (void)qmui_performBatchUpdates:(void (NS_NOESCAPE ^ _Nullable)(void))updates completion:(void (^ _Nullable)(BOOL finished))completion {
if (@available(iOS 11.0, *)) {
[self performBatchUpdates:updates completion:completion];
} else {
[self _performBatchUpdates:updates completion:completion];
}
}

@end
60 changes: 57 additions & 3 deletions QMUIKit/UIKitExtensions/UIViewController+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#import "UIViewController+QMUI.h"
#import "UINavigationController+QMUI.h"
#import "QMUINavigationController.h"
#import "QMUICore.h"
#import "UIInterface+QMUI.h"
#import "NSObject+QMUI.h"
Expand Down Expand Up @@ -244,12 +245,65 @@ - (CGFloat)qmui_navigationBarMaxYInViewCoordinator {
}
}

UINavigationBar *navigationBar = (!navigationController.navigationBarHidden && navigationController.navigationBar) ? navigationController.navigationBar : nil;

if (!navigationBar) {
if (!navigationController) {
return 0;
}

UINavigationBar *navigationBar = navigationController.navigationBar;
CGFloat barMinX = CGRectGetMinX(navigationBar.frame);
CGFloat barPresentationMinX = CGRectGetMinX(navigationBar.layer.presentationLayer.frame);
CGFloat superviewX = CGRectGetMinX(self.view.superview.frame);
CGFloat superviewX2 = CGRectGetMinX(self.view.superview.superview.frame);

if (self.qmui_navigationControllerPoppingInteracted) {
if (barMinX != 0 && barMinX == barPresentationMinX) {
// 返回到无 bar 的界面
return 0;
} else if (barMinX > 0) {
if (self.qmui_willAppearByInteractivePopGestureRecognizer) {
// 要手势返回去的那个界面隐藏了 bar
return 0;
}
} else if (barMinX < 0) {
// 正在手势返回的这个界面隐藏了 bar
if (!self.qmui_willAppearByInteractivePopGestureRecognizer) {
return 0;
}
} else {
// 正在手势返回的这个界面隐藏了 bar
if (barPresentationMinX != 0 && !self.qmui_willAppearByInteractivePopGestureRecognizer) {
return 0;
}
}
} else {
if (barMinX > 0) {
// 正在 pop 回无 bar 的界面
if (superviewX2 <= 0) {
// 即将回到的那个无 bar 的界面
return 0;
}
} else if (barMinX < 0) {
if (barPresentationMinX < 0) {
// 从无 bar push 进无 bar 的界面
return 0;
}
// 正在从有 bar 的界面 push 到无 bar 的界面(bar 被推到左边屏幕外,所以是负数)
if (superviewX >= 0) {
// 即将进入的那个无 bar 的界面
return 0;
}
} else {
if (superviewX < 0 && barPresentationMinX != 0) {
// 无 bar push 进有 bar 的界面时,背后的那个无 bar 的界面
return 0;
}
if (superviewX2 > 0) {
// 无 bar pop 回有 bar 的界面时,被 pop 掉的那个无 bar 的界面
return 0;
}
}
}

CGRect navigationBarFrameInView = [self.view convertRect:navigationBar.frame fromView:navigationBar.superview];
CGRect navigationBarFrame = CGRectIntersection(self.view.bounds, navigationBarFrameInView);

Expand Down

0 comments on commit 074a65e

Please sign in to comment.