use*_*621 2 compiler-construction xcode objective-c
我目前正在编写一个使用UITabBarController的iPhone应用程序,该应用程序包含5个以上的Tab Bar项目.因此,会自动生成"更多"标签(例如,在YouTube应用中).我发现相应的视图控制器类是UIMoreListController,但我没有任何相应的.h文件.所以,我的代码看起来像这样:
@class UIMoreListController; // can't use #import since .h file is missing
@implementation SomeUINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if ([viewController isKindOfClass:[UIMoreListController class]])
... // do something if "more" view is active
Run Code Online (Sandbox Code Playgroud)
这就像一个魅力.但是,编译器一直在给我
警告:接收者'UIMoreListController'是一个转发类,对应的@interface可能不存在
是否有一种巧妙的方法来摆脱这种警告(只有这个特别的警告)?同样,我不能使用#import,因为没有.h文件可用.
Ash*_*ark 10
如果您只是想检查UIMoreListController类,可以使用objc-api访问类变量.
if ([viewController isKindOfClass:NSClassFromString(@"UIMoreListController")])
Run Code Online (Sandbox Code Playgroud)
那你就不需要#import或@class声明了.
| 归档时间: |
|
| 查看次数: |
2659 次 |
| 最近记录: |