iPhone 创建嵌套视图
我是 iPhone 编程新手。
我想创建具有多个嵌套视图的基于导航的应用程序,其中第一个和第二个是 UITableView 类型,第三个是带有我自己的界面的简单 UIView,这是我在界面生成器中构建的。
当我运行应用程序时,触摸第一个表视图上的行,我转移到第二个,当我触摸第二个表视图上的行时,我转移到第三个,但在第三个视图上我看不到我的界面,我在 Interface Builder 中构建的,只是空白屏幕。
这是我的代码的一部分,我尝试在其中调用我的第三个视图:
if(self.reportView == nil){
ReportTypeViewController *viewController =
[[ReportTypeViewController alloc] initWithNibName:@"ReportTypeViewController"
bundle:[NSBundle mainBundle]];
self.reportView = viewController;
[viewController release];
}
[self.navigationController pushViewController:self.reportView animated:YES];
self.reportView.title = @"Reports";
没关系,伙计们。 我只是没有向我的按钮添加文本,它位于我的视图中,这就是为什么它是空白的。
I'm noob in iPhone programming.
I want to create navigation-based application with several nested views, when first and second are UITableView-type, and the third is simple UIView with my own interface, which I built in Interface builder.
When I run the App, touch the row on the first table-view I transfer to the second, and when I touch the row on the second, I transfer to the third, but on the third View I don't see my interface, which I built in Interface Builder, just blank screen.
This is part of my code, where I try to call my third view:
if(self.reportView == nil){
ReportTypeViewController *viewController =
[[ReportTypeViewController alloc] initWithNibName:@"ReportTypeViewController"
bundle:[NSBundle mainBundle]];
self.reportView = viewController;
[viewController release];
}
[self.navigationController pushViewController:self.reportView animated:YES];
self.reportView.title = @"Reports";
That's OK, guys.
I've just didn't add text to my button, that lies on my view, that's why it was blank.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不需要
[NSBundle mainBundle];
它应该如下所示:
如果您只是根据选择创建视图,那就容易得多。
You don't need
[NSBundle mainBundle];
it should look like this:
If you just create the view on demand with the selection it's much easier.
在 IB 中,请确保您记得将文件所有者的类设置为 ReportTypeViewController,并确保文件所有者的视图出口已连接到您的视图。
In IB, make sure you remembered to set the Class of File's Owner to
ReportTypeViewController
, and make sure that theview
outlet of File's Owner is connected to your view.ReportTypeViewController
真的继承自UIViewController
,还是像您所说的在 IB 中构建的UIView
?navigationController PushViewContoller:animated:
需要一个UIViewController
而不是UIView
。在 IB 中,您可以添加UIViewController
并将您的UIView
移至其上,或以编程方式创建它。Does
ReportTypeViewController
really inherit fromUIViewController
, or is it aUIView
, as you say you built in IB?navigationController pushViewContoller:animated:
needs aUIViewController
not aUIView
. In IB, you can add aUIViewController
and move yourUIView
onto it, or create it programmatically.