比如新建一个MyViewController
,如果不重写initWithNibName:bundle:
方法,在其他的类中也可以直接使用:
MyViewController *controller = [[MyViewController alloc] init]
重写这个方法除了具有修改功能外,还有什么作用?
伊谢尔伦2017-04-24 09:13:47
It’s okay without rewriting. Because MyViewController
是继承自UIViewController
, if it is not overridden, this method of the parent class will be automatically called.
Rewriting is usually done to do some initialization processing. In fact, the initialization processing is usually placed in viewDidLoad
. So what I see is that this method is generally not rewritten.