我有一个第一个表视图和一个推送到另一个表视图的 segue。当用户从第一个表视图中触摸一个单元格时,我已经能够推送第二个表视图,但我不能在第二个表视图中显示数据。我的第二个表格视图使用的是继承自 UITableViewController 的自定义控制器。我使用方法“cellForRowAtIndexPath:(NSIndexPath *)indexPath”将文本放入我的单元格中,但代码永远不会到达该方法。我不明白问题是什么。
这是我的自定义类:
    #import "TableViewControllerTop.h"
    @interface TableViewControllerTop ()
    @end
    @implementation TableViewControllerTop
    @synthesize tableView;
    @synthesize cells;
    - (id)initWithStyle:(UITableViewStyle)style
    {
        self = [super initWithStyle:style];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Uncomment the following line to preserve selection between presentations.
        // self.clearsSelectionOnViewWillAppear = NO;
        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        self.navigationItem.rightBarButtonItem = self.editButtonItem;
    }
    - (void)viewDidUnload
    {
        [self setTableView:nil];
        [self setCells:nil];
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    #pragma mark - Table view data source
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    #warning Potentially incomplete method implementation.
        // Return the number of sections.
        return 0;
    }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 6;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Top 50 list";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }
    // Configure the cell...
    cell.textLabel.text = @"Test";
    return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"selected");
}
@end
谢谢你的帮助。如有必要,我可以发布更多代码。