NSString * className = [NSString stringWithFormat:@"%@ViewController", _dataSource[indexPath.row]]; //创建视图控制器的Class //使用class间接使用类名,即使不加头文件,也能创建对象。 //编译器要求直接引用类名等标识符,必须拥有声明。 Class aVCClass = NSClassFromString(className); //创建vc对象 UIViewController * vc = [[aVCClass alloc] init]; [vc performSelector:@selector(setDatArray:) withObject:[_resultData objectForKey:_dataSource[indexPath.row]]]; [vc performSelector:@selector(setTitle:) withObject:_dataSource[indexPath.row]]; NSString * className = [NSString stringWithFormat:@"%@ViewController", _dataSource[indexPath.row]]; //创建视图控制器的Class //使用class间接使用类名,即使不加头文件,也能创建对象。 //编译器要求直接引用类名等标识符,必须拥有声明。 Class aVCClass = NSClassFromStri
根据类名创建ViewController
最新推荐文章于 2023-01-15 22:55:26 发布
NSString * className = [NSString stringWithFormat:@"%@ViewController", _dataSource[indexPath.row]]; //创建视图控制器的Class //使用class间接使用类名,即使不加头文件,也能创建对象。 //编译器要求直接引用类名等标识符,必须拥有声明。 Class aVCClass = NSClassFromString(className); //创建vc对象 UIViewController * vc = [[aVCClass alloc] init]; [vc performSelector:@selector(setDatArray:) withObject:[_resultData objectForKey:_dataSource[indexPath.row]]]; [vc performSelector:@selector(setTitle:) withObject:_dataSource[indexPath.row]]; NSString * className = [NSString stringWithFormat:@"%@ViewController", _dataSource[indexPath.row]]; //创建视图控制器的Class //使用class间接使用类名,即使不加头文件,也能创建对象。 //编译器要求直接引用类名等标识符,必须拥有声明。 Class aVCClass = NSClassFromStri