Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个.xib文件,其中包含两个视图,一个用于横向,另一个用于纵向。将两个视图连接到一个对象似乎是不可能的,这样我就可以避免为两个变量重复代码或使用数组循环。
.xib
是否可以在 Cocoa 的运行时连接对象?
您可以为这两个视图分配标签,并使用 viewWithTag 方法在运行时获取您需要的标签,然后将其分配给 self.view 或其他视图。
是的,您可以将一个 .xib 与两个视图一起使用。可能的条件是。
1)连接 .xib 文件上的这些视图,并使用其 IBOutlet 对象。然后您可以在设备方向上显示和隐藏。