gpt4 book ai didi

ios - self.PresentingViewController.title 是 [null]

转载 作者:行者123 更新时间:2023-11-28 22:24:30 24 4
gpt4 key购买 nike

我有一个模态细节 View Controller ,我需要获取显示它的 View Controller 的标题。我将以下代码附加到模态 Controller 中的按钮操作,但它始终返回 null:

NSLog(@"presnetingViewController.title=%@",[self presentingViewController].title);

日志:

presnetingViewController.title=(null)

我在 Storyboard 中设置了呈现 View Controller 的标题,我可以通过呈现 View Controller 中的方法以编程方式获取标题。

有什么想法吗?谢谢!

最佳答案

使用
NSLog(@"presnetingViewController.title=%@",[self presentingViewController].navigationItem.title);

如果您的呈现 View Controller 在导航 Controller 堆栈上,请使用

NSLog(@"presnetingViewController.title=%@",((UINavigationController *)[self presentingViewController]).topViewController.navigationItem.title);

关于ios - self.PresentingViewController.title 是 [null],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19366939/

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