【问题标题】:How to show a subview of xib into table cell load from another xib如何将 xib 的子视图显示到另一个 xib 的表格单元加载中
【发布时间】:2013-02-14 10:30:53
【问题描述】:

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

MainFile.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];                               
}

TestForm.m

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

(...)

return _testSummaryView;
}

【问题讨论】:

    标签: objective-c uitableview xib subview


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-13
      • 2021-06-04
      • 1970-01-01
      • 2011-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多