gpt4 book ai didi

ios - 我可以使用一个自定义创建的 UIViewController 来填充父 UITableViewController 的单元格文本值吗?

转载 作者:行者123 更新时间:2023-11-29 12:53:07 27 4
gpt4 key购买 nike

我创建了一个名为 SetValueVC 的自定义 ViewController,其中包含 UITextView。在我的应用程序中创建新产品时,我显示 UITableViewController 以及需要指定的单元格。如果用户单击某个单元格,我将我的 UIViewController 显示为 detailView 以允许设置父级 UITableViewCells detailLabel.text 值。我知道如何使用委托(delegate)从 subview 传递数据,但是当有例如 10 行时它是如何工作的?我应该为每一行创建 10 个委托(delegate)方法,还是只为 didselectForRow 方法中的每一行创建 SetValueVC 对象并只使用一个委托(delegate)方法?提前致谢

最佳答案

这可能是一个答案:使用单例并在您的ViewControllerUITableViewController

中使用您的模型

.h 中:

+(MyModel *)shared;

.m 中:

静态我的模型 *我的模型;

@implementation MyModel

+(MyModel *) shared{
if (nil != myModel) {
return myModel;
}

static dispatch_once_t pred;
dispatch_once(&pred, ^{
myModel = [[MyModel alloc] init];
});
return myModel;
}

通过这种方式,您可以在应用的任何位置访问您的模型。

希望对您有所帮助。

关于ios - 我可以使用一个自定义创建的 UIViewController 来填充父 UITableViewController 的单元格文本值吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21935417/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com