Skip to content

Commit eeb8c1c

Browse files
committed
1. TableViewEstimatedHeightEnabled 仅对 QMUITableView 和 UITableView 生效,不要动到别的 tableView 例如 UIPickerTableView; 2. QMUIPopupMenuView 内部的 UIScrollView 设置 behavior 为 never; 3. 为 QMUIAlertAction 的 handler 增加 QMUIAlertController 参数
1 parent 9222231 commit eeb8c1c

8 files changed

Lines changed: 23 additions & 19 deletions

File tree

QMUIKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "QMUIKit"
3-
s.version = "2.6.0"
3+
s.version = "2.6.1"
44
s.summary = "致力于提高项目 UI 开发效率的解决方案"
55
s.description = <<-DESC
66
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。

QMUIKit/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.6.0</string>
18+
<string>2.6.1</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

QMUIKit/QMUIComponents/QMUIAlertController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef NS_ENUM(NSInteger, QMUIAlertControllerStyle) {
5050
*
5151
* @return QMUIAlertController按钮的实例
5252
*/
53-
+ (instancetype)actionWithTitle:(NSString *)title style:(QMUIAlertActionStyle)style handler:(void (^)(QMUIAlertAction *action))handler;
53+
+ (instancetype)actionWithTitle:(NSString *)title style:(QMUIAlertActionStyle)style handler:(void (^)(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action))handler;
5454

5555
/// `QMUIAlertAction`对应的 button 对象
5656
@property(nonatomic, strong, readonly) QMUIButton *button;

QMUIKit/QMUIComponents/QMUIAlertController.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ @interface QMUIAlertAction ()
6161
@property(nonatomic, strong) QMUIAlertButtonWrapView *buttonWrapView;
6262
@property(nonatomic, copy, readwrite) NSString *title;
6363
@property(nonatomic, assign, readwrite) QMUIAlertActionStyle style;
64-
@property(nonatomic, copy) void (^handler)(QMUIAlertAction *action);
64+
@property(nonatomic, copy) void (^handler)(QMUIAlertController *aAlertController, QMUIAlertAction *action);
6565
@property(nonatomic, weak) id<QMUIAlertActionDelegate> delegate;
6666

6767
@end
6868

6969
@implementation QMUIAlertAction
7070

71-
+ (instancetype)actionWithTitle:(NSString *)title style:(QMUIAlertActionStyle)style handler:(void (^)(QMUIAlertAction *action))handler {
71+
+ (instancetype)actionWithTitle:(NSString *)title style:(QMUIAlertActionStyle)style handler:(void (^)(__kindof QMUIAlertController *, QMUIAlertAction *))handler {
7272
QMUIAlertAction *alertAction = [[QMUIAlertAction alloc] init];
7373
alertAction.title = title;
7474
alertAction.style = style;
@@ -1101,7 +1101,7 @@ - (void)handleMaskViewEvent:(id)sender {
11011101
- (void)didClickAlertAction:(QMUIAlertAction *)alertAction {
11021102
[self hideWithAnimated:YES completion:^{
11031103
if (alertAction.handler) {
1104-
alertAction.handler(alertAction);
1104+
alertAction.handler(self, alertAction);
11051105
alertAction.handler = nil;
11061106
}
11071107
}];

QMUIKit/QMUIComponents/QMUIDialogViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ extern const NSInteger QMUIDialogSelectionViewControllerSelectedItemIndexNone;
130130
/// 是否自动控制提交按钮的enabled状态,默认为YES,则当输入框内容为空时禁用提交按钮
131131
@property(nonatomic, assign) BOOL enablesSubmitButtonAutomatically;
132132

133-
@property(nonatomic, copy) BOOL (^shouldEnableSubmitButtonBlock)(QMUIDialogTextFieldViewController *dialogViewController);
133+
@property(nonatomic, copy) BOOL (^shouldEnableSubmitButtonBlock)(__kindof QMUIDialogTextFieldViewController *dialogViewController);
134134

135135
@end

QMUIKit/QMUIComponents/QMUIDialogViewController.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,8 @@ - (void)handleCancelButtonEvent:(QMUIButton *)cancelButton {
369369

370370
- (void)handleSubmitButtonEvent:(QMUIButton *)submitButton {
371371
if (self.submitButtonBlock) {
372-
// 把自己传过去,方便在block里调用self时不会导致内存泄露
373-
__weak QMUIDialogViewController *weakSelf = self;
374-
self.submitButtonBlock(weakSelf);
372+
// 把自己传过去,通过参数来引用 self,避免在 block 里直接引用 dialog 导致内存泄漏
373+
self.submitButtonBlock(self);
375374
}
376375
}
377376

QMUIKit/QMUIComponents/QMUIPopupMenuView.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ - (void)didInitialized {
9494
self.scrollView.scrollsToTop = NO;
9595
self.scrollView.showsHorizontalScrollIndicator = NO;
9696
self.scrollView.showsVerticalScrollIndicator = NO;
97+
if (@available(iOS 11, *)) {
98+
self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
99+
}
97100
[self.contentView addSubview:self.scrollView];
98101

99102
self.itemSeparatorLayers = [[NSMutableArray alloc] init];

QMUIKit/UIKitExtensions/UITableView+QMUI.m

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ - (instancetype)qmui_initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
2626
[self qmui_initWithFrame:frame style:style];
2727

2828
// iOS 11 之后 estimatedRowHeight 如果值为 UITableViewAutomaticDimension,estimate 效果也会生效(iOS 11 以前要 > 0 才会生效)。
29-
// 而当使用 estimate 效果时,会导致 contentSize 之类的计算不准确,所以这里给一个途径让项目可以方便地统一控制所有 UITableView(包括系统默认的)的 estimatedRowHeight 效果的开关
30-
if (TableViewEstimatedHeightEnabled) {
31-
self.estimatedRowHeight = TableViewCellNormalHeight;
32-
self.estimatedSectionHeaderHeight = TableViewCellNormalHeight;
33-
self.estimatedSectionFooterHeight = TableViewCellNormalHeight;
34-
} else {
35-
self.estimatedRowHeight = 0;
36-
self.estimatedSectionHeaderHeight = 0;
37-
self.estimatedSectionFooterHeight = 0;
29+
// 而当使用 estimate 效果时,会导致 contentSize 之类的计算不准确,所以这里给一个途径让项目可以方便地控制 QMUITableView(及其子类) 和 UITableView(不包含子类,例如 UIPickerTableView)的 estimatedRowHeight 效果的开关 https://github.com/QMUI/QMUI_iOS/issues/313
30+
if ([self isKindOfClass:NSClassFromString(@"QMUITableView")] || [NSStringFromClass(self.class) isEqualToString:@"UITableView"]) {
31+
if (TableViewEstimatedHeightEnabled) {
32+
self.estimatedRowHeight = TableViewCellNormalHeight;
33+
self.estimatedSectionHeaderHeight = TableViewCellNormalHeight;
34+
self.estimatedSectionFooterHeight = TableViewCellNormalHeight;
35+
} else {
36+
self.estimatedRowHeight = 0;
37+
self.estimatedSectionHeaderHeight = 0;
38+
self.estimatedSectionFooterHeight = 0;
39+
}
3840
}
3941
return self;
4042
}

0 commit comments

Comments
 (0)