I have a table view with dynamic cells generated in the class TableViewController. I made a segue to another table view (which inherits from TableViewController2). I want to trigger the display of the new table view when the user selects a cell from the first table view. I implemented prepareForSegue in TableViewController. The segue works, I can see the first table view pop off screen and the new table view pop in, but it's empty whatever I do. How can I trigger the display of the cells in TableViewController2?
In TableViewController:
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
if ([(segue.identifier) isEqualToString:@"topSegue"]){
TableViewController2 *navigationController = segue.destinationViewController;
TableViewController2 *tvc = segue.destinationViewController;
}
}
In TableViewController2:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Top 50 list";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = @"test";
return cell;
}
Did you define the following two methods in your second tvc?
and
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.