2010-04-06 95 views

回答

1

有幾種方法可以做到這一點,但我傾向於用關聯的XIB文件創建一個UITableViewCell衍生物。在Interface Builder中修改XIB以包含按鈕和標籤。將這些對象綁定到UITableViewCell類中的IBOutlets和IBActions。

當你實現你的cellForRowAtIndexPath你可以抓住從你的UITableViewCell XIB文件中像這樣的頂級對象:

NSArray * topLevelObjects = [[NSBundle mainBudnle] loadNibNamed:@"YourCellNib" owner:self options:nil]; 
cell = [topLevelOjects objectAtIndex:0]; 

你可以再投你的對象添加到您的UITableViewCell類:

YourCellClass * thingCell = (YourCellClass*)cell; 

然後,您可以使用YourCellClass來控制UITableView中的單元格(並從中接收事件)。

相關問題