iOS 根据字符串创建控制器

2017-07-19  本文已影响0人  woailuoli
    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];
    }
上一篇下一篇

猜你喜欢

热点阅读