ios - Outlets 无法连接重复内容 iOS 5

标签 ios uitableview

我是 iOS 新手,我正在处理 uitableview 单元格,我已将按钮拖放到对象检查器中的表格 View 单元格。但是当我制作它的 IBoutlet 时,它显示一个错误,如“Outlets cannot be connected to repeating content”,这是什么意思?我们不能在 tableview 单元格中制作 UIbutton 的导出。请检查它。我被困在里面了。我正在做一个这样的 socket :

@property (weak, nonatomic) IBOutlet UIButton *sa;

错误是“UIbutton 的 sa outlet 无效”

最佳答案

你的答案是你通过重用它来使用 UITableViewCell 中的一个对象,

所以你不能创建它的导出,除非你为你的“UITableViewCell”创建你的类。

以下是您的引用,

希望对你有用。

您需要将对象拖放到 UITableViewCell 中, 然后您必须为该对象提供标签。

然后你就可以用它的标签了。

首先给UITableViewCell一个标识符,

下面是它的引用图片。

enter image description here

然后给你的UI对象一个标签, 就像这张引用图片中的那样。

enter image description here

下面是我经常使用的示例代码,

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


    UITableViewCell *Cell = [self.TableListRegion dequeueReusableCellWithIdentifier:@"List"];

    UIButton *objectOfButton = (UIButton *)[CellLast viewWithTag:200];

    [objectOfButton addTarget:self action:@selector(YourSelector:) forControlEvents:UIControlEventTouchUpInside];

    return Cell;

}

现在您可以通过以下方式接收该按钮事件,

-(IBACTION)YourSelector:(id)sender{
// Your Button in Cell is selected.
// Do your stuff.

}

如果您需要更多帮助,请随时询问。

关于ios - Outlets 无法连接重复内容 iOS 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27142581/

相关文章:

ios - Xcode,来自 Jenkins/SSH 的代码设计错误 - "User Interaction is not allowed"

html - 移动 Safari 上的切碎占位符

ios - 从表格 View 到详细信息的 Segue 不起作用

ios - 动态 UITableViewCell 不根据内容调整大小

ios - 从数据库中检索数据后重新加载 UiTableView - Swift

iOS 方向更改调整大小

ios - 如何在 Parse 的安装类中应用更新删除查询?

ios - 从自定义 UIViewController 导航到 TabBarController 没有 segue

ios - 使用 Expandable UITableView 只显示一行

ios - 当单元格有值时,Swift TableViewCell 为空