Best idea for importing text to each NavigationController View(将文本导入每个 NavigationController 视图的最佳方法)
问题描述
大家好,我想构建一个诗歌应用程序,所以我想使用 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.
关于导航控制器:
表格视图上方应该只有一个导航控制器.当您想显示一首诗的详细信息时,您只需创建一个带有关联 XIB 的 PoemDetailsViewController,在 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 视图的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将文本导入每个 NavigationController 视图的最佳方法
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
