我目前需要的是通过子类化 UIViewController 并在不使用任何 nib 文件的情况下应用必要的方法,以编程方式创建一个 tableview。它可能需要一个 UINavigationViewControlloer。我基本上了解所有这些概念,甚至几乎知道如何将所有内容拼凑在一起,但缺少一些东西。它将有 4 个文件。 AppDelegate h/m 和 SomeNameViewcontroller h/m。我认为 SomeNameViewController 应该有一个属性 UITableView*
我已经尝试了几种方法并在网上查看,但我一直收到带有导航栏的黑屏。令人难以置信的令人沮丧,当我可以让 tableView 显示时,我无法让 tableView 重新加载数据:/
最佳答案
从您的叙述来看,您似乎没有完全掌握所涉及的概念。例如,没有 UINavigationViewController
这样的东西。 .以下是您需要知道的:
UINavigationController
是 View Controller 的 Controller 。 您可以在您的应用委托(delegate)中创建它
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:
yourRootViewController];
并使用
self.navigationController
从 View Controller 访问它.UITableViewController
的子类。 . Xcode 中的模板应该已经有所有 datasource
的 stub 。和 delegate
你需要的方法。 在
application:didFinishLaunchingWithOptions:
:self.window.rootViewController = nav; // the nav controller you created
[nav release];
[self.window makeKeyAndVisible];
return YES;
关于iphone - 子类 UIViewController 以编程方式创建列表而不使用 nib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7292743/