获取控制器的名称 [英] Getting the name of a Controller

查看:60
本文介绍了获取控制器的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带TabBarController的iPhone应用程序.我可以使用

I have an iPhone application with a TabBarController. I can access the current ViewController with

[appDelegate.myTabBarController selectedViewController]

但是如何获取此控制器的名称?

But how can I get the name of this controller?

例如,所选ViewController的名称为"TestViewController".如何获得此字符串/名称?我想检查当前的ViewController是否为"TestViewController".

For example the name of the selected ViewController is "TestViewController". How can I get this string/name? I want to check if the current ViewController is "TestViewController".

非常感谢&最好的问候.

Thanks a lot in advance & Best Regards.

推荐答案

您可以按照以下方式进行操作:

You can do this in this manner:

if([[appDelegate.myTabBarController selectedViewController] isKindOfClass:[TestViewController class]])
{
NSLog(@"Yes I am the controller you want.");
}

希望这会有所帮助.

这篇关于获取控制器的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆