Browse Source

1.修改UWAVER Model Detail DropDown最大高度以及点击DropDown区域外隐藏并从父视图移除。

Pen Li 7 years ago
parent
commit
e813925fd5

+ 8 - 1
RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

@@ -30,6 +30,7 @@
 
 #import "ModelDescriptionController.h"
 
+
 #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
 #import "HomerModelDetailHeaderCell.h"
 #endif
@@ -475,12 +476,18 @@ self.isrefreshing=false;
     if(self.dropDown == nil)
     {
         CGFloat height = 70*selector_count;
+        if (selector_count > 4) {
+            height = 70 * 4.5;
+        }
         self.dropDown =[[NIDropDown alloc] showDropDown:self.detailTable based:(id)trigger height:height data:self.selector direction:@"down" current_sel:current_sel];
         
         
         //Capturing strongly  warring;
         __block DetailViewController *brself= self;
-        
+        self.dropDown.dropDownTouchOutsideBlk = ^{
+            [brself.dropDown hideDropDown:(id)trigger];
+            brself.dropDown= nil;
+        };
         self.dropDown.selectChanged =^(long index){
             
             

+ 1 - 0
RedAnt ERP Mobile/common/customUI/NIDropDown.h

@@ -25,6 +25,7 @@
 - (id)showDropDown:(UIView*)container based:(UIButton *)b height:(CGFloat )height data:(NSDictionary *)json direction:(NSString *)direction current_sel:(long) current_sel;
 
 @property (nonatomic , copy) void (^selectChanged)(long index);
+@property (nonatomic,copy) void(^dropDownTouchOutsideBlk)(void);
 
 @property (strong,nonatomic) NSDictionary* selector;
 @property long current_sel;

+ 37 - 9
RedAnt ERP Mobile/common/customUI/NIDropDown.m

@@ -126,15 +126,25 @@
 -(void)hideDropDown:(UIButton *)b {
     CGRect btn = b.frame;
     
-    [UIView beginAnimations:nil context:nil];
-    [UIView setAnimationDuration:0.3];
-    if ([animationDirection isEqualToString:@"up"]) {
-        self.frame = CGRectMake(btn.origin.x, btn.origin.y, btn.size.width, 0);
-    }else if ([animationDirection isEqualToString:@"down"]) {
-        self.frame = CGRectMake(btn.origin.x, btn.origin.y+btn.size.height, btn.size.width, 0);
-    }
-    table.frame = CGRectMake(0, 0, btn.size.width, 0);
-    [UIView commitAnimations];
+//    [UIView beginAnimations:nil context:nil];
+//    [UIView setAnimationDuration:0.3];
+//
+//    [UIView commitAnimations];
+    
+    [UIView animateWithDuration:0.3 animations:^{
+        
+        if ([self->animationDirection isEqualToString:@"up"]) {
+            self.frame = CGRectMake(btn.origin.x, btn.origin.y, btn.size.width, 0);
+        }else if ([self->animationDirection isEqualToString:@"down"]) {
+            self.frame = CGRectMake(btn.origin.x, btn.origin.y+btn.size.height, btn.size.width, 0);
+        }
+        self.table.frame = CGRectMake(0, 0, btn.size.width, 0);
+        
+    } completion:^(BOOL finished) {
+        
+        [self removeFromSuperview];
+        
+    }];
 }
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
@@ -269,4 +279,22 @@
 //    [self release];
 }
 
+#pragma mark - Touch
+
+- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
+    BOOL inside = [super pointInside:point withEvent:event];
+    
+    CGPoint btnPoint = [self convertPoint:point toView:btnSender];
+    BOOL btnInside = [btnSender pointInside:btnPoint withEvent:event];
+    
+    
+    if (!inside && !btnInside) {
+        if (self.dropDownTouchOutsideBlk) {
+            self.dropDownTouchOutsideBlk();
+        }
+    }
+    
+    return inside;
+}
+
 @end