Skip to content

Commit

Permalink
1. TableViewEstimatedHeightEnabled 仅对 QMUITableView 和 UITableView 生效,…
Browse files Browse the repository at this point in the history
…不要动到别的 tableView 例如 UIPickerTableView; 2. QMUIPopupMenuView 内部的 UIScrollView 设置 behavior 为 never; 3. 为 QMUIAlertAction 的 handler 增加 QMUIAlertController 参数
  • Loading branch information
MoLice committed Apr 27, 2018
1 parent 9222231 commit eeb8c1c
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion QMUIKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "QMUIKit"
s.version = "2.6.0"
s.version = "2.6.1"
s.summary = "致力于提高项目 UI 开发效率的解决方案"
s.description = <<-DESC
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。
Expand Down
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>2.6.0</string>
<string>2.6.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIComponents/QMUIAlertController.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef NS_ENUM(NSInteger, QMUIAlertControllerStyle) {
*
* @return QMUIAlertController按钮的实例
*/
+ (instancetype)actionWithTitle:(NSString *)title style:(QMUIAlertActionStyle)style handler:(void (^)(QMUIAlertAction *action))handler;
+ (instancetype)actionWithTitle:(NSString *)title style:(QMUIAlertActionStyle)style handler:(void (^)(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action))handler;

/// `QMUIAlertAction`对应的 button 对象
@property(nonatomic, strong, readonly) QMUIButton *button;
Expand Down
6 changes: 3 additions & 3 deletions QMUIKit/QMUIComponents/QMUIAlertController.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ @interface QMUIAlertAction ()
@property(nonatomic, strong) QMUIAlertButtonWrapView *buttonWrapView;
@property(nonatomic, copy, readwrite) NSString *title;
@property(nonatomic, assign, readwrite) QMUIAlertActionStyle style;
@property(nonatomic, copy) void (^handler)(QMUIAlertAction *action);
@property(nonatomic, copy) void (^handler)(QMUIAlertController *aAlertController, QMUIAlertAction *action);
@property(nonatomic, weak) id<QMUIAlertActionDelegate> delegate;

@end

@implementation QMUIAlertAction

+ (instancetype)actionWithTitle:(NSString *)title style:(QMUIAlertActionStyle)style handler:(void (^)(QMUIAlertAction *action))handler {
+ (instancetype)actionWithTitle:(NSString *)title style:(QMUIAlertActionStyle)style handler:(void (^)(__kindof QMUIAlertController *, QMUIAlertAction *))handler {
QMUIAlertAction *alertAction = [[QMUIAlertAction alloc] init];
alertAction.title = title;
alertAction.style = style;
Expand Down Expand Up @@ -1101,7 +1101,7 @@ - (void)handleMaskViewEvent:(id)sender {
- (void)didClickAlertAction:(QMUIAlertAction *)alertAction {
[self hideWithAnimated:YES completion:^{
if (alertAction.handler) {
alertAction.handler(alertAction);
alertAction.handler(self, alertAction);
alertAction.handler = nil;
}
}];
Expand Down
2 changes: 1 addition & 1 deletion QMUIKit/QMUIComponents/QMUIDialogViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ extern const NSInteger QMUIDialogSelectionViewControllerSelectedItemIndexNone;
/// 是否自动控制提交按钮的enabled状态,默认为YES,则当输入框内容为空时禁用提交按钮
@property(nonatomic, assign) BOOL enablesSubmitButtonAutomatically;

@property(nonatomic, copy) BOOL (^shouldEnableSubmitButtonBlock)(QMUIDialogTextFieldViewController *dialogViewController);
@property(nonatomic, copy) BOOL (^shouldEnableSubmitButtonBlock)(__kindof QMUIDialogTextFieldViewController *dialogViewController);

@end
5 changes: 2 additions & 3 deletions QMUIKit/QMUIComponents/QMUIDialogViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,8 @@ - (void)handleCancelButtonEvent:(QMUIButton *)cancelButton {

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

Expand Down
3 changes: 3 additions & 0 deletions QMUIKit/QMUIComponents/QMUIPopupMenuView.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ - (void)didInitialized {
self.scrollView.scrollsToTop = NO;
self.scrollView.showsHorizontalScrollIndicator = NO;
self.scrollView.showsVerticalScrollIndicator = NO;
if (@available(iOS 11, *)) {
self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[self.contentView addSubview:self.scrollView];

self.itemSeparatorLayers = [[NSMutableArray alloc] init];
Expand Down
20 changes: 11 additions & 9 deletions QMUIKit/UIKitExtensions/UITableView+QMUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ - (instancetype)qmui_initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
[self qmui_initWithFrame:frame style:style];

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

0 comments on commit eeb8c1c

Please sign in to comment.