最好的想法,导入文本到每个NavigationController视图 [英] Best idea for importing text to each NavigationController View
问题描述
大家好,我想要一个诗的应用程序,所以我想使用NavigationControlle显示每首诗!我的意思是我有一个TableView和那里+ 50诗!
每个单元格都有不同的诗歌!所以我可以做什么导入每个文本或HTML文件(我的Pomes)到特殊的视图,那工作与导航控制器?
是否是好主意使用NSArray在表视图上显示诗细胞?
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?
像这样
**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 !
-----------------
推荐答案
关于表格单元格:
创建表格单元格的推荐方法是使用 UITableView
'
- (UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier
并将单元格的子视图值重新设置为当前行/诗的属性。
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.
关于导航控制器:
您应该在表视图上方只有一个导航控制器。当你想显示一首诗的详细信息,你只需创建一个 PoemDetailsViewController
与关联的XIB,设置IB中的子视图,连接它们,然后当用户点击表格行,在你的UITableView的委托:
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];
}
导航控制器将自动设置您的后退按钮和一切, PoemDetailsView
有一个导航项。
The navigation controller will automatically set up your back button and everything, just make sure the PoemDetailsView
has a navigation item.
这篇关于最好的想法,导入文本到每个NavigationController视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!