0

出于某种原因,我将 navigatioController 子类化以覆盖 pushViewController 方法:

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    NSLog(@"Pushing %@ to NavigationController", viewController);
    if([[self viewControllers] containsObject:viewController])
    {
        if( [self topViewController] == viewController )
        {
            NSLog(@"Pushed ViewController is already on top!");
        }
        else
        {
            NSLog(@"Moving Pushed ViewController to top!");
            [self popToViewController:viewController animated:animated];
        }
    }
    else
    {
        [super pushViewController:viewController animated:animated];
    }
    NSLog(@"NavigationControllers: %@", [self viewControllers]);
}

一切正常,但是每当我有一行代码时,视图控制器被推送到导航控制器时,我都会收到警告:

Incompatible pointer types sending 'NMROViewController *' to parameter of type 'UIViewController *'

这有点“令人不安”。好的,方法签名需要一个 UIVIewController,但它是刚刚被我的代码覆盖的“原始”。

我想,一定有什么,我不知道要“压制”或“避免”警告。

还是我必须生成不止一种方法!?

提前致以亲切的问候...

4

1 回答 1

0

好的,解决方案就这么简单。我忘了在开始时导入正确的 .h 文件

于 2013-07-28T15:26:10.450 回答