Przeglądaj źródła

优化dialog逻辑

zzb 4 lat temu
rodzic
commit
c6b775f9f2

+ 12 - 0
ZZUIKit/Classes/Tools/ZZViewProtocol.h

@@ -0,0 +1,12 @@
+//
+//  ZZViewProtocol.h
+//  ZZUIKit
+//
+//  Created by Max on 2021/2/7.
+//
+
+#ifndef ZZViewProtocol_h
+#define ZZViewProtocol_h
+
+
+#endif /* ZZViewProtocol_h */

+ 0 - 1
ZZUIKit/Classes/ZZDialog/ZZDialogViewController.h

@@ -11,7 +11,6 @@
 NS_ASSUME_NONNULL_BEGIN
 
 @protocol ZZDialogDelegate <ZZDialogContenDelegate>
-@optional
 -(CGRect)preferredFrameForDialog:(ZZDialog *)dialog;
 
 @end

+ 14 - 13
ZZUIKit/Classes/ZZDialog/ZZDialogViewController.m

@@ -9,7 +9,7 @@
 #import "ZZUIKitEx.h"
 #import "ZZMaskView.h"
 
-@interface ZZDialogViewController ()<ZZDialogContenDelegate,ZZDialogHandleDelegate>
+@interface ZZDialogViewController ()<ZZDialogDelegate,ZZDialogHandleDelegate>
 @property(nonatomic,strong,readwrite) ZZDialog *dialog;
 @property(nonatomic,strong) ZZMaskView *maskView;
 @end
@@ -18,14 +18,16 @@
 
 -(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
     if (self == [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
-        [self commonInit];
+        self.definesPresentationContext = true;
+        self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
     }
     return self;
 }
 
 -(instancetype)initWithCoder:(NSCoder *)coder{
     if (self == [super initWithCoder:coder]) {
-        [self commonInit];
+        self.definesPresentationContext = true;
+        self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
     }
     return self;
 }
@@ -34,18 +36,17 @@
     [super awakeFromNib];
 }
 
--(void)commonInit{
-    self.definesPresentationContext = true;
-    self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
-    self.maskView = [[ZZMaskView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W(), SCREEN_H())];
-    __weak typeof(self) weakSelf = self;
-    [self.view insertSubview:self.maskView atIndex:0];
-    self.maskView.zz_tapAction(^(UIView *v){
-        [weakSelf.dialog dismiss];
-    });
-    [self.view addSubview:self.dialog];
+-(void)viewDidLoad{
+   self.maskView = [[ZZMaskView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W(), SCREEN_H())];
+   __weak typeof(self) weakSelf = self;
+   [self.view insertSubview:self.maskView atIndex:0];
+   self.maskView.zz_tapAction(^(UIView *v){
+       [weakSelf.dialog dismiss];
+   });
+   [self.view addSubview:self.dialog];
 }
 
+
 #pragma mark -- set
 - (void)setMaskColor:(UIColor *)maskColor{
     _maskColor = maskColor;