ios中的file's owner

从stackoverflow上看到的。

Two points to be remembered :

  • The File owner is the object that loads the nib . Ie. that object which receives the message loadNibNamed: or initWithNibName: .
  • So if you want to access any objects in the nib from the object after loading it , you set an outlet to the the file owner                                 
我自己的理解是这样的,如果自己弄了一个自定义控件作为customView,然后loadNibName来加载xib文件,那么file‘s owner最好就不要用了,因为customView就可以专门处理这个xib所需要对应的IBOutlet和IBAction,如果自己没有弄这样的一个customView,那么可以将file‘s owner设定为某一个VC或者自定义的类用来处理和加载Xib文件,注意这个file's owner必须要和loadNibName方法里面的owner是一致的,不管在什么情况下。


猜你喜欢

转载自blog.csdn.net/arceushs/article/details/54972914
今日推荐