ios - 如何在不同的 UItableViewController 中重用 Storyboard 中创建的 UITableViewCell View ?

标签 ios objective-c mobile uitableview storyboard

您好,我在 Storyboard 的 ControllerA 中创建了 UITableViewCell。我需要在不同的 ControllerB 中使用相同的 UITableViewcell。我只需要通过 Storyboard 来实现这一点。 知道我该怎么做吗?

最佳答案

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

在 Storyboard中,您必须将另一个 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;

}

关于ios - 如何在不同的 UItableViewController 中重用 Storyboard 中创建的 UITableViewCell View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18380682/

相关文章:

javascript - 检测 ios11 设备是否处于低功耗模式,以防止在正常正确自动播放视频时出现不良用户体验

ios - 使用 Mac 数据包记录器进行蓝牙 LE 跟踪

ios - 在 SpriteKit 中暂停游戏并显示菜单

android - 将 Realm 对象服务器用于协作应用程序

ios - 如何从函数内部获取 JSON 数据并将其显示在 swift 的文本字段上?

带有 Swift 的 iOS : App crashes on UITableView scroll down event

objective-c - 无法在 Mac 上使用 ARC 使用 respondsToSelector

ios - 通过数组排序 - Objective-C/iOS

audio - 无需语音识别即可检测多个声音

html - css @media 移动/桌面 : ensuring desktop doesn't show mobile css