我有一個應用程序,顯示可以購買的產品列表。對於列表中的視圖控制器看起來像這樣:如何在視圖控制器中獲得對UITableView的引用?
@interface InAppPurchaseListUIItemViewController :
UIViewController <UITableViewDelegate, UITableViewDataSource> {
IBOutlet UITableView *_inAppPurchaseListTable;
.
.
.
}
.
.
.
@end
這是一個顯示清單的代碼:
_inAppPurchaseListUIItemViewController = [[InAppPurchaseListUIItemViewController alloc]
initWithItemList: [[InAppPurchaseManager getInstance] getAuthorisedInAppPurchaseProducts]
: self
andSelector: @selector(inAppPurchaseSelected:)
];
_inAppPurchaseListCustomUIView= [[InAppPurchaseListCustomUIView alloc]
initWithFrame:CGRectMake(0, 0, inapp_purchase_table_width, inapp_purchase_table_height)];
[_inAppPurchaseListCustomUIView addSubview:_inAppPurchaseListUIItemViewController.view];
_inAppPurchaseListUIItemViewController.view.frame = _inAppPurchaseListCustomUIView.frame;
InAppPurchaseListCustomUIView
子類UIView
和否則是一個空類。
還有一個與視圖控制器同名的.xib。 .xib似乎包含一個表視圖,沒有別的。
該列表顯示正常,但現在我想更改顯示的項目。我有一張支持桌子的NSMutableArray
。當我改變陣列時,我需要讓UITableView
重新繪製新陣列,但_inAppPurchaseListTable
總是零。
- 如何獲得對UITableView的引用,以便我可以撥打
reloadData
? - 無論如何,我可以擺脫.xib?我沒有看到一個額外的文件,除了保存一個表格視圖之外什麼都不做。
連接督察
您是否使用xib文件連接了_inAppPurchaseListTable! – Scar 2012-03-29 21:38:45
在.xib中,使用Connections Inspector,您有哪些網點鏈接到表視圖?特別是在「參考插座」部分?另外,initWithItemList:方法是什麼樣的? – 2012-03-29 21:43:57
@Scar,我該怎麼做? – Jay 2012-03-29 21:53:35