Quellcode durchsuchen

Move the delegate interface of enum selector to the public header file -- 把enum selector 的委托接口移到公共头文件里。(issue70: #14156)

Ray Zhang vor 5 Jahren
Ursprung
Commit
48fe4b62c9

+ 1 - 0
common/customUI/commoneditor/CommonEditorViewController.m

@@ -4769,6 +4769,7 @@
             enumvc.delegate = self;
             enumvc.max_select = max_select;
             enumvc.updatePosition = indexPath;
+            enumvc.online_params = item_json[@"params"];
             //        if([[required lowercaseString] isEqualToString:@"true"])
             //        enumvc.canbeEmpty = false;
             //        else

+ 5 - 5
common/customUI/commoneditor/EnumSelectOnlineViewController.h

@@ -12,11 +12,11 @@
 NS_ASSUME_NONNULL_BEGIN
 
 @class EnumSelectOnlineViewController;
-@protocol EnumSelectOnlineViewControllerDelegate <NSObject>
-
--(void) EnumValueChanged:(NSMutableDictionary *)value indexPath :(NSIndexPath*) indexPath;
-
-@end
+//@protocol EnumSelectOnlineViewControllerDelegate <NSObject>
+//
+//-(void) EnumValueChanged:(NSMutableDictionary *)value indexPath :(NSIndexPath*) indexPath;
+//
+//@end
 
 @interface EnumSelectOnlineViewController : UIViewController<UITableViewDataSource,UITableViewDelegate,UISearchBarDelegate>
 

+ 34 - 20
common/customUI/commoneditor/EnumSelectOnlineViewController.m

@@ -27,6 +27,7 @@
 
 
 @property (strong,nonatomic) NSMutableDictionary* cadedate;
+@property (strong,nonatomic) NSMutableDictionary* online_cadedate;
 @property int offset ;
 @property int limit ;
 //@property (nonatomic,strong) NSArray<NSMutableDictionary *> *dataArray;
@@ -48,6 +49,9 @@
 {
     [super viewDidLoad];
     
+    
+    self.limit = 20;
+    
 //    self.automaticallyAdjustsScrollViewInsets = NO;
 //    self.max_select = 0;
     
@@ -150,12 +154,12 @@
 {
     [super viewWillDisappear:animated];
     if(self.dirty == false)
-    return;
+        return;
     if (self.delegate && [self.delegate respondsToSelector:@selector(EnumValueChanged:indexPath:)]) {
-        [self.delegate EnumValueChanged:self.cadedate indexPath:self.updatePosition];
+        [self.delegate EnumValueChanged:self.online_cadedate indexPath:self.updatePosition];
     }
     if(self.returnValue)
-        self.returnValue(self.cadedate);
+        self.returnValue(self.online_cadedate);
 }
 
 
@@ -404,23 +408,31 @@
         
         if(self.keywords==nil || self.keywords.length==0)
         {
-            for(int i=0;i<[[self.cadedate valueForKey:@"count"] intValue];i++)
-            {
-                
-                
-                
-                
-                NSMutableDictionary* val_json = [[self.cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]] mutableCopy];
-                if(i==indexPath.row)
-                    [val_json setValue:@"1" forKey:@"check"];
-                else
-                    [val_json setValue:@"0" forKey:@"check"];
-                [self.cadedate setObject:val_json forKey:[NSString stringWithFormat:@"val_%d",i]];
-            }
+            
+            NSMutableDictionary* val_json = [[self.cadedate objectForKey:[NSString stringWithFormat:@"val_%ld",indexPath.row]] mutableCopy];
+            [val_json setValue:@true forKey:@"check"];
+            
+            self.online_cadedate = [NSMutableDictionary new];
+            
+            self.online_cadedate[@"count"]=@1;
+            self.online_cadedate[@"val_0"]=val_json;
+//            for(int i=0;i<[[self.cadedate valueForKey:@"count"] intValue];i++)
+//            {
+//                
+//                
+//                
+//                
+//                NSMutableDictionary* val_json = [[self.cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]] mutableCopy];
+//                if(i==indexPath.row)
+//                    [val_json setValue:@"1" forKey:@"check"];
+//                else
+//                    [val_json setValue:@"0" forKey:@"check"];
+//                [self.cadedate setObject:val_json forKey:[NSString stringWithFormat:@"val_%d",i]];
+//            }
         }
         else
         {
-            
+            NSAssert(true, @"NOT IMPL");
 
             
             NSMutableDictionary* val_json =nil;
@@ -558,7 +570,7 @@
 #pragma mark - searchBar delegate;
 - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
 {
-    self.keywords=[searchBar.text uppercaseString];
+    self.online_keywords=[searchBar.text uppercaseString];
    
     [self loadData];
  //   [self.tableEnum reloadData];
@@ -600,13 +612,15 @@
     
     
     NSMutableDictionary *params = [self.online_params mutableCopy];
+    if(params==nil)
+        params=[NSMutableDictionary new];
     [params setObject:[NSNumber numberWithInteger:self.offset] forKey:@"offset"];
     [params setObject:[NSNumber numberWithInteger:self.limit] forKey:@"limit"];
     
    if(self.online_keywords.length>0)
-       self.online_params[@"keywords"]=self.online_keywords;
+       params[@"keywords"]=self.online_keywords;
 
-    [RADataProvider GetCadedate:self.online_params completionHandler:^(NSMutableDictionary *result) {
+    [RADataProvider GetCadedate:params completionHandler:^(NSMutableDictionary *result) {
         
         NSMutableDictionary * json = result;
             __strong typeof(weakSelf) strongSelf = weakSelf;