如何以编程方式创建UIViewController?

编程入门 行业动态 更新时间:2024-10-09 06:28:42
本文介绍了如何以编程方式创建UIViewController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在一个应用程序中工作,我有 UITableView 中的数据。它就像一个向下钻取的应用程序。用户将单击一行,将转到下一页,显示 UITableView 中的更多记录。但在我的情况下的问题是,我不知道用户可以钻多少级别。级别数量不固定。所以现在我想以编程方式创建和添加viewcontrollers。可能吗??如果有,怎么样? 提前感谢。

I am working in a app where i have data in UITableView. It is like a drill down application. User will click on a row and will go to next page showing more records in a UITableView. But problem in my case is that i dont know upto how many level user can drill. The number of levels are not fixed. So now i am thinking to create and add the viewcontrollers programmatically. Is it possible?? if yes how? thanks in advance.

推荐答案

UIViewController *controller = [[UIViewController alloc] init]; controller.view = whateverViewYouHave;

您是否拥有自己编码的视图控制器?在这种情况下,您可能不需要设置视图属性,因为它已在IB中设置,如果这是您使用的。当你拥有你的控制器时,你可以将它推到navigationController上或以模态方式查看它。

Do you have your own view controller that you coded? In that case you probably don't need to set the view property as it has been set in IB if that is what you used. When you have your controller you can push it onto the navigationController or view it modally etc.

更多推荐

如何以编程方式创建UIViewController?

本文发布于:2023-11-28 11:15:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642175.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方式   UIViewController

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!