將 xib 從一個項目複製到另一個項目 (copy the xib from one project to another project)


問題描述

將 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!enter image description here

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.

enter image description here

方法 2:

May be it will help you.... Click your .xib file and add the class name. Like thisenter image description here

方法 3:

When copying you need to setup the class and outlet connections.

Follow these steps:

  1. Copy the xib
  2. Add the class name of your xib in it's files owner

Class

  1. Add the outlets

Outlets

(by Srivathsarohan‑patelSudha TiwariMidhun MP)

參考文件

  1. copy the xib from one project to another project (CC BY‑SA 2.5/3.0/4.0)

#iboutlet #iphone #iOS #xib #ipad






相關問題

iOS - IB 視圖模式 (iOS - IB view mode)

NSWindow 的 IBOutlet 組件什麼時候初始化? (When IBOutlet components of NSWindow are initialized?)

收到內存警告和內存洩漏 (Receive memory warning and memory leak)

如何在 init 方法中從 NIB 加載 IBOutlets? (How to load the IBOutlets from NIB in the the init method?)

將 xib 從一個項目複製到另一個項目 (copy the xib from one project to another project)

將案例編碼到 appDelegate 文件中 (The case(s) coding into appDelegate file)

nib 中的 UIView 在 iPad 上是 nil,在 iPhone 上不是 nil (UIView in nib is nil on iPad, and not nil on iPhone)

awakeFromNib 無法從 UILabel 獲取值,也無法禁用 UIButton (awakeFromNib can't get value from UILabel and can't disable UIButton)

“找不到名為 ViewController 的類的任何信息” ("Could not find any information for class named ViewController")

在 Xcode 7 中將出口從文件連接到情節提要 (Connect outlet from file to storyboard in Xcode 7)

為什麼“文件所有者”有時會有“視圖”出口?我可以添加我自己的嗎? (Why does "File's Owner" sometimes have a "view" outlet? Can I add my own?)

Interface Builder 中的 IBOutletCollection 集排序 (IBOutletCollection set ordering in Interface Builder)







留言討論