忘不了的石楠花 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没有设置数据源和代理。

    评论

报告相同问题?

悬赏问题

  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换