在 iOS 应用程序中更改 rootviews 视图类型

发布于 2024-11-19 05:15:43 字数 418 浏览 8 评论 0原文

在创建基于导航的应用程序时,它会自动创建一个根视图控制器,该控制器是 UITableViewController 的子类,但在 MainWindow.xib 中,如您所知,我看不到 UITableView 放置在根视图控制器下,但我们将表视图拖放到那里。我们可以简单地拖放 UIView 而不是 UITableView 并更改根视图控制器类以子类化 uiview 而不是 UITableView并改变它的方法?

或者我必须在IB中拖动一个UITableView作为根视图控制器?我是初学者,我不想做复杂的事情,那么使用 UIView 作为根的最简单方法是什么。如果那不简单,我会坚持使用表格视图。

While creating a navigation based application, it automatically creates a root view controller which subclasses UITableViewController, but in MainWindow.xib as you know I can't see a UITableView is placed under root view controller but we drag and drop a table view there. Can we simply drag and drop a UIView instead of a UITableView and change the root view controller class to sublass a uiview instead of UITableView and change its methods?

Or I must drag a UITableView in IB for the root view controller? I am a beginner and I do not want to make complicated things so what is the simplest way of using a UIView as a root. If thats not simple I will stick with the table view.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

肥爪爪 2024-11-26 05:15:43

是的,你可以改变。您只需要更改界面生成器中的一些绑定,并将 rootViewController 的超类更改为 UIViewController 而不是 UITableViewController。

更新

首先打开 rootViewController.xib 并从其中删除 tableiew 并拖放 UIView。绑定该视图以查看文件所有者中的属性。将 rootViewController 的超类从 UITableViewController 更改为 UIViewController。就是这样。

这是屏幕截图。

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

Yes you can change. You just need to change some bindings in inteface builder and change rootViewController's superclass to UIViewController instead of UITableViewController.

UPDATE

First open the rootViewController.xib and delete the tableiew from there and drag-n-drop a UIView. Bind that View to view property in file-owner. Change superclass of rootViewController from UITableViewController to UIViewController. That's it.

Here are the screenshots.

enter image description here

enter image description here

enter image description here

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文