iOS 根据字符串创建控制器

    NSString *className = self.classNames[indexPath.row]; //classNames 字符串数组集
    Class class = NSClassFromString(className);
    if (class) {
        UIViewController *ctrl = class.new;
        ctrl.title = _titles[indexPath.row]; //_titles 标题数组集
        [self.navigationController pushViewController:ctrl animated:YES];
    }

你可能感兴趣的:(iOS 根据字符串创建控制器)