views:

108

answers:

1

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 different poem ! so what can i do to import each text or HTML Files(My Pomes) to special view , that work with navigation controller ? is it good idea to use NSArray to show poem cells on the table view?

Like this

**TABLE VIEW**

Poem 1 >
-------------
Poem 2 >
-------------
Poem 3 >
-------------
Poem 4 >
------------
Poem 5 >

Poem 1 :
Say hello to world 
say hello to sky 
-----------------
Poem 2 :
Sea is blue 
Jungle is green !
-----------------
+2  A: 

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.

Prody
@Momeks, just ask here, it's free, and if I'm not around to answer someone else will. :)
Prody
Specifically, you should post another question using the “Ask Question” form. It's bad to post multiple questions on the same question (and doesn't get good results).
Peter Hosey
@Prody : can you more explain to me ? how it's works? and how must create .poem class ?
Momeks