2

我从 xib 文件加载 xib 子视图 [TestSummaryView] 到表格单元 [NotesTableCell] 时遇到问题。我的 xib 子视图只有在通过拖出屏幕刷新单元格后才可见。

主文件.m:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{

NotesTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"NotesTableCell"];
if (cell == nil) 
{
    [[NSBundle mainBundle] loadNibNamed:@"NotesTableCell" owner:self options:nil];
    cell = __noteTableCell;
    self.__noteTableCell = nil;
}

(...)

for (UIView* view in [cell.summaryView subviews])
    [view removeFromSuperview];

UIView* view = [note.form summaryView];
[cell.summaryView addSubview:view];
view.bounds = cell.summaryView.bounds;
view.center = CGPointMake(cell.summaryView.bounds.size.width/2, cell.summaryView.bounds.size.height/2);

[cell.webView setHidden:YES];
[cell.summaryView setHidden:NO];                               
}

测试表格.m

-(UIView*)summaryView 
{
if (!_testSummaryView) 
{
    NSArray* xib = [[NSBundle mainBundle] loadNibNamed:@"TestSummaryView" owner:self options:nil];
    _testSummaryView = [[xib objectAtIndex:0] retain];
}

(...)

return _testSummaryView;
}
4

1 回答 1

0

问题解决了。它在代码的其他部分。

于 2013-02-18T09:33:38.833 回答