InitWithNibName和viewDidLoad? [英] InitWithNibName and viewDidLoad?

查看:92
本文介绍了InitWithNibName和viewDidLoad?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
initWithNibName VS viewDidLoad

Possible Duplicate:
initWithNibName VS viewDidLoad

我是iOS开发的新手.我想知道这两个功能之间的主要区别吗?

I'm new at iOS development. I would just like to know the main differences between these 2 functions ?

感谢您的帮助

推荐答案

    viewDidLoad

在视图加载并初始化/取消存档并加载到内存中时调用.这是一个很棒的定制站.

Is called when the view loads and is initiated/Unarchived and loaded into the memory. This is a great customisation stop.

 initWithNibName:

用于用xib文件的名称初始化某个类(它是重写的init方法),bundle参数指定文件的位置,您将为主要包(项目文件夹)传递nil.

Is used for initializing a certain class ( it is an overriden init method) with a xib file's name, the bundle parameter specifies the location of the file, you would pass nil for the main bundle, which is the projects folder.

您应该在viewDidLoad中设置属性.从nib File创建控制器实例时,会调用initWithNibName:.我不会在其中放置自定义代码.

You should set up your properties in the viewDidLoad. The initWithNibName: is something that you call when you create a controller instance from a nib File. I wouldn't put customisation code there.

这篇关于InitWithNibName和viewDidLoad?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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