忘不了的石楠花 2015-09-15 08:03 采纳率: 0%
浏览 1484

关于table跳转的疑虑,手写了为什么跳转不了(只写了前两个单元格),我是小白请原谅

#import "RootTableViewController.h"
#import "TableViewController_1.h"
#import "TableViewController_2.h"
@interface RootTableViewController ()

@end

@implementation RootTableViewController

  • (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置";
    _muArr = @[@[@"飞行模式",@"无线局域网",@"蓝牙",@"蜂窝移动网络",@"个人热点",@"运营商"],@[@"通知",@"控制中心",@"勿扰模式"]];
    }

  • (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

  • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [_muArr count];
    }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return ((NSArray *)_muArr[section]).count;
    }

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"rootCellIdentifier" forIndexPath:indexPath];
    if (cell == nil) {
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"rootCellIdentifier"];
    }
    cell.textLabel.text = [((NSArray *)_muArr[indexPath.section]) objectAtIndex:(indexPath.row)];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
    }

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
TableViewController_1 *table_1 = [[TableViewController_1 alloc]init];
TableViewController_2 *table_2 = [[TableViewController_2 alloc]init];
UIViewController *uiviewcontroller = [[UIViewController alloc]init];
if (indexPath.section == 0) {
switch (indexPath.row) {
case 0:
uiviewcontroller = table_1;
break;
case 1:
uiviewcontroller = table_2;
break;
default:
break;
}
}

[self.navigationController pushViewController:uiviewcontroller animated:YES];

}
@end
/****************/
#import "TableViewController_1.h"

@interface TableViewController_1 ()

@end

@implementation TableViewController_1

  • (void)viewDidLoad {
    [super viewDidLoad];
    _arr_1 = @[@[@"你该吃药了",@"你病的不轻"],@[@"我是医生",@"我是你的医生",@"我是你一辈子的医生"]];
    }

  • (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    }

#pragma mark - Table view data source

  • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return _arr_1.count;
    }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return ((NSArray *)_arr_1[section]).count;
    }

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellIdentifier" forIndexPath:indexPath];

    // Configure the cell...
    if (cell == nil) {
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellIdentifier"];
    }
    cell.textLabel.text = ((NSArray *)_arr_1[indexPath.section])[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
    }

  • 写回答

1条回答 默认 最新

  • LUCKEYMAN 2015-09-15 10:32
    关注

    tableview没有设置数据源和代理。

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料