如何在不同的UItableViewController中重用在Storyboard中创建的UITableViewCell视图?

时间:2013-08-22 12:37:31

标签: ios objective-c mobile uitableview storyboard

您好我在Storyboard的 ControllerA 中创建了UITableViewCell。我需要在不同的 ControllerB 中使用相同的UITableViewcell。我只需要用故事板来实现这个目标。 知道我该怎么做呢?

1 个答案:

答案 0 :(得分:1)

你可以像下面这样使用它: -

在故事板中你必须将另一个Table-cell放入ControllerB nib并为它提供类似自定义单元格的类名称,如下所示: -

enter image description here

enter image description here

你的ControllerB的cellForRowAtIndexPath看起来像这样

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

    Members_Cell *cell  = [tableView dequeueReusableCellWithIdentifier:@"Members_Cell"];

    cell.lblMemberName.text=[ArrSearchResult objectAtIndex:indexPath.row];

    return  cell;

}