NSString *className = [curDict valueForKey: @"menu_val"];
Class ctrlClass = NSClassFromString(className);
//YBaseViewController 是父类
YBaseViewController *ctrl = [[ctrlClass alloc] init];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
[self.navigationItem setBackBarButtonItem:backItem];
ctrl.hidesBottomBarWhenPushed = YES;
// 跳转
[self.navigationController pushViewController: ctrl animated: YES];
步骤总结:
1、提取字串为NSString;
2、转化为class,Class ctrlClass = NSClassFromString(className);
3、实例化, YBaseViewController *ctrl = [[ctrlClass alloc] init];
4、呈现。