【发布时间】:2017-07-04 16:44:24
【问题描述】:
我一直在关注有关 iOS 开发的教程 - 特别是深入了解 UITableViews。我建立了自己的自定义 plist,但似乎无法让 DetailViewController 填充我的 plist 信息。我真的可以在这里使用一些帮助,我有点过头了!
编辑:这里有一些细节......
应用程序通过一个 plist 填充的 RootViewController 运行,它是一个 UITableView。当 plist 中没有任何子级时,它会更改为 Detail 视图:
AppDelegate.m
NSDictionary *tempDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"]];
self.data = tempDict;
RootViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
if(CurrentLevel == 0) { // At the 'root' of the plist
//Initilalize our table data source
NSArray *tempArray = [[NSArray alloc] init];
self.tableDataSource = tempArray;
AppDelegate *AppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.tableDataSource = [AppDelegate.data objectForKey:@"Rows"];
self.navigationItem.title = @"PedalTome";
}
else
self.navigationItem.title = CurrentTitle;
}
稍后...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//Get the dictionary of the selected data source.
NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
//Get the children of the present item.
NSArray *Children = [dictionary objectForKey:@"Children"];
if([Children count] == 0) {
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController animated:YES];
}
else {
//Prepare to tableview.
RootViewController *rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];
//Increment the Current View
rvController.CurrentLevel += 1;
//Set the title;
rvController.CurrentTitle = [dictionary objectForKey:@"Title"];
//Push the new table view on the stack
[self.navigationController pushViewController:rvController animated:YES];
rvController.tableDataSource = Children;
}
}
我的DetailViewController.m 为空,但占位符self.navigationController.title 除外。
如果我理解正确,我需要将信息从RootViewController 传递到DetailViewController - plist 的位置和实现、plist 中的索引级别(就是它的名称)以及里面的字符串该索引级别(在 Detail 键下)。
在这一点上,任何进步都是惊人的进步。提前致谢。
【问题讨论】:
-
嘿克里斯蒂安,我相信有人会在接下来的 5 秒内回答这个问题,但要获得更一般的 Objc/iOS 帮助,请查看jlawr3nc3.github.com,这是我目前正在处理的示例集合。
-
美丽的网站杰克。我已将其添加为书签以供将来参考。有什么与这个问题相关的吗?
-
谢谢,使用 documentup.com 从我的 github README 降价文件生成。我在下面回答了你的问题。随意使用 cmets 部分提问/告诉我我完全错了:)
标签: ios uitableview uiview