Browse Source

动态类 对象创建

hxb 8 years ago
parent
commit
c73664af57

BIN
WSCloudStorage.xcworkspace/xcuserdata/jonathanh.xcuserdatad/UserInterfaceState.xcuserstate


+ 3 - 3
WSCloudStorage.xcworkspace/xcuserdata/jonathanh.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -106,11 +106,11 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "WSCloudStorage/VC/TabBarMore/PreferencesViewController.m"
-            timestampString = "523965546.234607"
+            timestampString = "524568967.26805"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "182"
-            endingLineNumber = "182"
+            startingLineNumber = "183"
+            endingLineNumber = "183"
             landmarkName = "-initSubViews"
             landmarkType = "5">
          </BreakpointContent>

+ 1 - 1
WSCloudStorage/VC/TabBarMore/BAGridView/BAGridItemModel.h

@@ -28,5 +28,5 @@
 /**
  *  对于激活类名
  */
-@property(nonatomic, copy) NSString *className;
+@property(nonatomic, copy) id classWithName;
 @end

+ 9 - 11
WSCloudStorage/VC/TabBarMore/PreferencesViewController.m

@@ -8,6 +8,7 @@
 
 #import "PreferencesViewController.h"
 #import "BAKit_BAGridView.h"
+#import "RecyleViewController.h"
 static NSString * const kCellID = @"PreferencesViewControllerCellID";
 #define AvatarWH 60
 #define ProgressH 8
@@ -51,30 +52,30 @@ static NSString * const kCellID = @"PreferencesViewControllerCellID";
         NSArray *array = @[@{
                                @"title":@"联系人列表",
                                @"image":tmpimage,
-                               @"class":@"ContactListClass"},
+                               @"class":[NSObject class]},//ContactListClass
                            @{
                                @"title":@"回收站",
                                @"image":tmpimage,
-                               @"class":@"ReCyleViewController"},
+                               @"class":[RecyleViewController class]},
                            @{
                                @"title":@"主题",
                                @"image":tmpimage,
-                               @"class":@"ThemeViewController"},
+                               @"class":[NSObject class]},//ThemeViewController
                            @{
                                @"title":@"通讯录同步",
                                @"image":tmpimage,
-                               @"class":@"SyncAddressBookViewController"},
+                               @"class":[NSObject class]},//SyncAddressBookViewController
                            @{
                                @"title":@"正在研发",
                                @"image":tmpimage,
-                               @"class":@"DevelopingViewController"}
+                               @"class":[NSObject class]}//DevelopingViewController
                            ];
         for (NSDictionary *dict in array) {
             BAGridItemModel *model = [BAGridItemModel new];
             model.imageName = dict[@"image"];
             model.placdholderImageName = @"tabbar_mainframeHL";
             model.titleString = dict[@"title"];
-            model.className = dict[@"class"];
+            model.classWithName = dict[@"class"];
             [self.gridDataArray addObject:model];
         }
         
@@ -179,13 +180,10 @@ static NSString * const kCellID = @"PreferencesViewControllerCellID";
         weakSelf.gridView = tempView;
         
     } block:^(BAGridItemModel *model, NSIndexPath *indexPath) {
-        const char className = model.className;
-        Class kclass = objc_getClass(&className);
+        //const char className = model.className;
+        UIViewController *kclass = [model.classWithName new];
         if (kclass) {
-            Class superClass = [UIViewController class];
-            kclass = objc_allocateClassPair(superClass, &className, 0);
             [weakSelf.navigationController pushViewController:kclass animated:YES];
-
         }
 
         NSLog(@"tap:%@",indexPath);

+ 20 - 3
WSCloudStorage/VC/TabBarMore/RecyleViewController.m

@@ -7,23 +7,40 @@
 //
 
 #import "RecyleViewController.h"
-
+#import "CSFileCell.h"
 @interface RecyleViewController ()
-
+@property (nonatomic,weak)UITableView *tableView;
 @end
 
 @implementation RecyleViewController
 
 - (void)viewDidLoad {
     [super viewDidLoad];
+    self.title = @"回收站";
     // Do any additional setup after loading the view.
+    [self initSubView];
 }
 
 - (void)didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];
     // Dispose of any resources that can be recreated.
 }
-
+- (void)initSubView{
+    CGFloat screenH = SCREEN_HEIGHT;
+    CGFloat screenW = SCREEN_WIDTH;
+    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
+    [self.view addSubview:tableView];
+    self.tableView = tableView;
+    CALayer *layer = [CALayer layer];
+    layer.frame = CGRectMake(0, screenH-44, screenW, 44);//44-30 = 14  7   7
+    layer.backgroundColor = RGB(121, 121, 121).CGColor;
+    UIButton *clearAllBtn = [UIButton buttonWithType:UIButtonTypeSystem];
+    clearAllBtn.frame = CGRectMake(40, layer.frame.origin.y+7, screenW -80, 30);
+    [clearAllBtn setTitle:@"一键清空" forState:UIControlStateNormal];
+    clearAllBtn.backgroundColor = RGB(132,178,237);
+    [self.view addSubview:clearAllBtn];
+    
+}
 /*
 #pragma mark - Navigation
 

+ 13 - 0
WSCloudStorage/VC/TabBarMore/test.h

@@ -0,0 +1,13 @@
+//
+//  test.h
+//  cloudstorage
+//
+//  Created by JonathanH on 2017/8/16.
+//  Copyright © 2017年 wswinsoft. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface test : NSObject
+
+@end

+ 13 - 0
WSCloudStorage/VC/TabBarMore/test.m

@@ -0,0 +1,13 @@
+//
+//  test.m
+//  cloudstorage
+//
+//  Created by JonathanH on 2017/8/16.
+//  Copyright © 2017年 wswinsoft. All rights reserved.
+//
+
+#import "test.h"
+
+@implementation test
+
+@end