IB中的對象和外部對象有什麼區別?
什麼時候應該使用每個?XCode Interface Builder中的對象與外部對象
7
A
回答
3
一個對象是實際嵌入在筆尖中的東西。
一個外部對象是加載nib承諾在加載時提供的代碼(我相信通過將鍵映射到外部對象的字典)。
除了文件所有者(已經爲您提供)之外,大多數人從不使用任何外部對象。你幾乎肯定只需要對象。
6
添加到其他答案: 您可以使用'外部對象'來訪問跨多個xib的通用對象。你也可以用其他方式做到這一點,但這會很方便。
舉個例子,如果你有一個'大'行動來執行多個xib的按鈕點擊,並且如果你有很多這樣的動作(另外如果它是你執行這個動作的相同數據),而不是調用addTarget:action...
,您可以創建該類的代理對象並將其連接到按鈕。
id *proxy = <someObject>; //The object you want to wire up
//In the below line of code use the same key as the identifier you give for the proxy object in the Interface Builder
UINib *nib = [UINib nibWithNibName:@"ViewController" bundle:Nil];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:proxyObject,@"proxy", nil];
NSDictionary *dict2 = [NSDictionary dictionaryWithObjectsAndKeys:dict,UINibExternalObjects, nil];
NSArray *nibArray = [nib instantiateWithOwner:self options:dict2];
self.view = [nibArray objectAtIndex:0];
相關問題
- 1. Xcode Interface Builder - 在框架外顯示對象?
- 2. 如何從Xcode 5中的Interface Builder中移除對象?
- 3. Interface Builder不會在現有的XCode項目中顯示對象?
- 4. 的iOS空Interface Builder的對象
- 5. XCode 4 Interface Builder:如何訪問繪製的對象
- 6. XCode Interface Builder:更改已放置對象的類
- 7. Xcode/Interface Builder,爲對象標籤使用定義/常量
- 8. 如何使用Autosize功能顯示Interface Builder中的對象?
- 9. 將消息發送到在Interface Builder中創建的對象
- 10. 與Interface Builder中
- 11. 的Xcode,Interface Builder中和StackView
- 12. Xcode:在Interface Builder中將對象指定爲UITableView數據源/代理
- 13. Objective-C/Cocoa:什麼是Interface Builder/Nib中的「Application」代理對象?
- 14. 如何將自定義UIButton添加到Interface Builder對象庫?
- 15. 與Interface Builder中
- 16. Xcode/Interface Builder崩潰
- 17. 如何在Interface Builder中添加自定義對象?
- 18. 從Shadertoy在Interface Builder(Xcode中)
- 19. 爲什麼Interface Builder對象不顯示在屏幕上?
- 20. 創建與「舊」的對象引用Builder模式新對象
- 21. 需要訪問Interface Builder對象的圖像文件
- 22. 添加GUI類/控件到Interface Builder的對象庫
- 23. 爲使用Interface Builder添加的對象釋放內存
- 24. 什麼時候可以設置Interface Builder對象的屬性?
- 25. chrome.storage.sync.get與外層對象同步,但內部對象不同步?
- 26. 從內部類對象中獲取外部類對象
- 27. 從內部類對象中獲取外部類對象
- 28. 如何添加在Interface Builder對象原型細胞
- 29. 加載前設置對象(通過Interface Builder添加)屬性?
- 30. 無法滾動到UIViewController的底部XCode 5 Interface Builder編輯或添加摺疊下的對象
時,我會用每能否請您提供例如:
您可以使用下面的代碼連接代理對象的廈門國際銀行? (只是想法不代碼)。謝謝。 – RCB 2013-02-28 19:16:54
@RCB:幾乎所有的筆尖都是某種物體。如果要嵌入IB不知道的類的對象,則可以使用字面值對象。您可以通過編輯新對象的Class值來完成此操作。直接使用對象並不常見。至於外部對象,你可能不需要這樣做。 – 2013-02-28 19:51:40