我有一个应用程序,显示可以购买的产品列表。对于列表中的视图控制器看起来像这样:如何在视图控制器中获得对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