美文网首页
TableView didselected 方法中简洁代码

TableView didselected 方法中简洁代码

作者: Just丶Go | 来源:发表于2017-05-26 09:55 被阅读0次
  1. 首先集体做的是push 操作.
  2. 先将跳转的目标类 以类名的字符串格式存储在一个数组中
@property (nonatomic,strong) NSArray *dataSourceArray;
_dataSourceArray = @[@"LineVC",@"SlipLineVC",@"CandleLineVC",@"TimeLineVC"];
  1. 在didselected方法中 根据下标indexPath.row 获取对应角标的 类名字符串
  2. 获取类名字符串对应的类
  3. 创建 实例对象
  4. push操作
NSString *vcName = _dataSourceArray[indexPath.row];
    Class class = NSClassFromString(vcName);
    UIViewController *vc = [[class alloc] init];
    [self.navigationController pushViewController:vc animated:YES];

相关文章

网友评论

      本文标题:TableView didselected 方法中简洁代码

      本文链接:https://www.haomeiwen.com/subject/gsmtfxtx.html