Best idea for importing text to each NavigationController View

后端 未结 1 395
囚心锁ツ
囚心锁ツ 2021-01-25 03:53

Hi everyone i want build a poem application so i want use to NavigationControlle for show each poem ! i mean i have a TableView and on there + 50 poems ! each cell have differen

相关标签:
1条回答
  • 2021-01-25 03:55

    Regarding the table cells: The recommended way of creating table cells is to use UITableView's
    - (UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier
    and re-set the cell's subview values to the current row/poem's properties.

    Regarding the navigation controller:

    You should just have one navigation controller above the table view. When you want to show a poem's details, you just create a PoemDetailsViewController with an associated XIB, set up the sub-views in IB, connect them, then when a user clicks a table row, in your UITableView's delegate:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        PoemDetailsViewController *poemDetails = [[[PoemDetailsViewController alloc] initWithNibName:@"PoemDetailsViewController" bundle:nil] autorelease];
        poemDetails.poem = [poems objectAtIndex:indexPath.row]; // assuming you have a single dimension array with poems and a single table group
        [self.navigationController pushViewController:poemDetails animated:YES];
    }
    

    The navigation controller will automatically set up your back button and everything, just make sure the PoemDetailsView has a navigation item.

    0 讨论(0)
提交回复
热议问题