在 iOS 应用程序中更改 rootviews 视图类型
在创建基于导航的应用程序时,它会自动创建一个根视图控制器,该控制器是 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,你可以改变。您只需要更改界面生成器中的一些绑定,并将 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.