在IOS 4.x或更低版本中,viewDidAppear方法在将视图添加到视图时不会被调用,为什么? [英] In IOS 4.x or lower, viewDidAppear method is not getting called while adding subview to a view, why?

查看:195
本文介绍了在IOS 4.x或更低版本中,viewDidAppear方法在将视图添加到视图时不会被调用,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 4.x或更低版本中,viewDidAppear和viewWillAppear,viewDidDisappear和viewWillDisappear,这样的ViewController的委托方法没有被调用。相同的方法与iOS 5.x相同。

In iOS 4.x or lower, viewDidAppear and viewWillAppear, viewDidDisappear and viewWillDisappear, such ViewController's delegate methods are not getting called. The same methods work fine with the iOS 5.x.

为什么?是iOS 4.x或更低版本的错误。因为在iOS 5.x中,所有这些方法都以正确的方式和顺序被调用。

Why? Is it a bug in iOS 4.x or lower. Because in iOS 5.x all those methods gets called in proper manner and sequence.

提前感谢
Mrunal

Thanks in advance, Mrunal

推荐答案

对于IOS4.xi,使用UINavigationController代理方法,如下所示:

For IOS4.x i use the UINavigationController delegate methods like this:

-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
        [activeView viewDidAppear:YES];
    }
}
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
        [activeView viewWillAppear:YES];
    }
}

希望这有帮助!

这篇关于在IOS 4.x或更低版本中,viewDidAppear方法在将视图添加到视图时不会被调用,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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