xib 文件中的自定义 class 和文件所有者设置有什么区别?
What's the difference between custom class and file's owner setting in xib file?
在自定义的xib文件中,如下图所示的两种设置方式有什么区别?
请检查此 link:
What is the File's Owner (in Interface builder)?
confused difference between Custom Class for an Object and for the File's Owner and steps via IB
在第一个屏幕截图中:您应该设置视图的自定义 class。
在第二个屏幕截图 (files owner
) 中,您可以将文件的所有者设置为您的 UIView 子class,以便您可以将插座连接到它
当您使用 XIB
添加自定义 UIView
时,您会在某些 UIViewController
中初始化此自定义视图并写入:
let nib = UINib(nibName: "CardView", bundle: nil)
let view = nib.instantiate(withOwner: self, options: nil).first as! CardView
文件的所有者(在 withOwner:
参数中)这通常是所有者是 ViewController 您添加自定义的地方
UIView
在自定义的xib文件中,如下图所示的两种设置方式有什么区别?
请检查此 link: What is the File's Owner (in Interface builder)? confused difference between Custom Class for an Object and for the File's Owner and steps via IB
在第一个屏幕截图中:您应该设置视图的自定义 class。
在第二个屏幕截图 (files owner
) 中,您可以将文件的所有者设置为您的 UIView 子class,以便您可以将插座连接到它
当您使用 XIB
添加自定义 UIView
时,您会在某些 UIViewController
中初始化此自定义视图并写入:
let nib = UINib(nibName: "CardView", bundle: nil)
let view = nib.instantiate(withOwner: self, options: nil).first as! CardView
文件的所有者(在 withOwner:
参数中)这通常是所有者是 ViewController 您添加自定义的地方
UIView