gpt4 book ai didi

objective-c - Apple 的 AdvancedTableViewCells 问题

转载 作者:行者123 更新时间:2023-12-03 20:59:33 25 4
gpt4 key购买 nike

我正在查看 Apple 的“AdvancedTableViewCells”示例项目,在查看 RootViewController 时,我注意到 IndividualSubviewsBasedApplicationCell 的 Nib 加载。我想知道 Nib 加载...它加载到什么中?没有句柄/变量。我理解下面的行,其中单元格通过 IBOutlet 分配给 View ,但我不理解该行:[[NSBundle mainBundle] loadNibNamed:@"IndividualSubviewsBasedApplicationCell"owner:self options :nil];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ApplicationCell";

ApplicationCell *cell = (ApplicationCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

#if USE_INDIVIDUAL_SUBVIEWS_CELL
[[NSBundle mainBundle] loadNibNamed:@"IndividualSubviewsBasedApplicationCell" owner:self options:nil];
cell = tmpCell;
self.tmpCell = nil;

最佳答案

请参阅 Jeff LaMarche 的文章 Table View Cells in Interface Builder - the Apple Way™ .

在NIB文件IndividualSubviewsBasedApplicationCell中,“File's Owner”设置为RootViewController,并且自定义UITableViewCell连接到 RootViewController 的 tmpCell IBOutlet

行中:

[[NSBundle mainBundle] loadNibNamed:@"IndividualSubviewsBasedApplicationCell" owner:self options:nil];

...捆绑加载器加载 NIB 文件并连接所有 socket 。完成此操作后,tmpCell IBOutlet 现在指向我们的自定义 UITableViewCell

关于objective-c - Apple 的 AdvancedTableViewCells 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2076403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com