调用superview的viewwill的意思是什么? [英] What is meaning of calling superview's viewwillappear?

查看:209
本文介绍了调用superview的viewwill的意思是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   - (void)viewwillAppear 
{
[super viewwillAppear:animated];
}

调用的意思是什么[super viewwillAppear:animated ] c>

super 你正在调用方法的基类版本。您将在 init dealloc viewDidLoad 等等。原因是在基类的实现中,一些重要的可能被执行,没有它,派生类将无法正常工作。当您在派生类中覆盖了方法时,您需要使用 super 来调用基本版本。



使用 super 不会调用基类方法的唯一情况是,当您知道需要由基类执行的任务,换句话说,你是完全压倒。这不是 viewWillAppear:animated viewDidLoad 等情况。因此我们在这些情况下总是调用super。 p>

-(void)viewwillAppear
{
[super viewwillAppear:animated];
}

What does mean of calling [super viewwillAppear:animated] and what happen if we not call it?

解决方案

By using super you are calling the base class version of the method. You will see similar call in init, dealloc, viewDidLoad etc. methods. The reason is in base class's implementation something important may be carried out without which the derived class will not work properly. When you have overridden the method in derived class, you will need to make a call to the base version by using super.

The only situation you will not call base class's method by using super is when you know that you don't need the tasks carried out by base class, in other words you are overriding completely. This is not the situation with viewWillAppear:animated or viewDidLoad etc. So we always call super in these cases.

这篇关于调用superview的viewwill的意思是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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