問題描述
將 xib 從一個項目複製到另一個項目 (copy the xib from one project to another project)
我需要將 xib 文件從一個項目複製到另一個項目。這可能是基本的東西,但我是 xib 文件使用的新手。
我手動複製了 xxx.h、xxx.m 和 xxx.xib 來自 project‑1 並保存在一個文件夾中,並將它們包含在另一個項目中作為“右鍵單擊 Project‑2 文件夾 ‑> 將文件添加到 Project‑2”選項。
(1) 複製後我丟失了一些 IBOutlet 連接
(2) Xib 不允許有新的 IBOutlet 變量。
然後我從原始位置(Project‑1 文件夾)複製文件,然後
(3) 如果我創建新的 IBOutlet 連接,則引用變量如果我訪問我得到零值。
參考解法
方法 1:
There may be two issues I sense in your copying.
1) While you are copying check option : "Copy selected items to destination folder". refer screenshot!
2) Also in your .xib file select File's owner ‑‑> Go to Identity Inspector in right top corner and select suitable class for that xib. When you add xib independently you have to set it's class manually like this.
方法 2:
May be it will help you.... Click your .xib file and add the class name. Like this
方法 3:
When copying you need to setup the class and outlet connections.
Follow these steps:
- Copy the xib
- Add the class name of your xib in it's files owner
- Add the outlets
(by Srivathsa、rohan‑patel、Sudha Tiwari、Midhun MP)