繁体   English   中英

使用故事板设置UITableViewController的委托

[英]Setting delegate of a UITableViewController using Storyboards

我正在尝试使用Storyboards设置UITableViewController的委托。 我遇到的问题是,我要设置的UITableViewController的委托不仅仅是简单的初始视图控制器目标。 因此,我决定启动应用程序后将使用此方法:

- (void)viewDidLoad {
AddListTermsViewController *addListTerms = [self.storyboard instantiateViewControllerWithIdentifier:@"AddListTerms"];
addListTerms.delegate = self;
}

然后,我像这样设置UITableViewController的Storyboard ID:

在此处输入图片说明

但是,当我启动UITableViewController并记录委托时,会收到null。 有任何想法吗? 提前致谢。

编辑

当我像这样将输出记录在初始视图控制器中时,得到一个肯定的结果:

AddListTermsViewController *addListTerms = (AddListTermsViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"AddListTerms"];
addListTerms.delegate = self;
NSLog(@"%@", addListTerms.delegate);

但是当我在UITableViewController上记录输出时,我再次收到null

我猜你需要将Storyboadcontroller类型转换为AddListTermsViewController

尝试这个

  AddListTermsViewController *addListTerms = (AddListTermsViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"AddListTerms"];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM