ios - 将 UITableViewCell 中的 UIButton 转换为自定义类不起作用

标签 ios objective-c uitableview uibutton

我创建了一个继承自 UIButton 的自定义切换按钮类。我将按钮添加到 Storyboard上的 UITableViewCell,并在 Identity Explorer 的自定义 -> 类部分中分配了类“LmxStartStopToggleButton”。对于 UITableViewCell,我还创建了一个自定义类“LmxRijtijdTableViewCell”并按住 ctrl 键拖动到 IBOutlet“rijtijdBtn”

@property IBOutlet LmxStartStopToggleButton *rijtijdBtn;

这个类的@interface。一切正常。 但之后我想在初始化时从 UITableViewCell 中操纵按钮的外观。运行时它似乎不是“LmxStartStopToggleButton”类型,而是 UITableViewCellContentType 类型,我无法转换为它。如果无法转换,如何在按钮上调用函数?或者如果我在 Identity Explorer 中设置它,为什么最初的类型不正确?

LmxStartStopToggleButton *btn = ((LmxStartStopToggleButton *)self.rijtijdBtn); 

enter image description here

最佳答案

确保您的单元格中没有其他元素指向“rijtijdBtn”。

如果这不是问题,请确保按钮的类型为“LmxStartStopToggleButton”,方法是单击界面编辑器中的按钮,转到右侧工具栏右侧的第 3 个选项卡,然后确保在“自定义”下类”它说“LmxStartStopToggleButton。”

关于ios - 将 UITableViewCell 中的 UIButton 转换为自定义类不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32186998/

相关文章:

ios - UITableViewCells 中 UIButton 的操作

ios - 按数字索引 UITableview 部分

ios - 是否可以使用自动布局获取动态表格 View 部分标题高度?

c++ - 回声打印实现

iphone - ios4 中不显示外部视频

objective-c - 委托(delegate)应该通过 Controller 来获取模型吗?

ios - 如何使用 Obj-C 在 iOS 中播放 mp3

ios - BLE后台扫描iOS

ios - 为什么我有一个地址为“0x30000000”的对象?

ios - UIScrollView/UITableView 分层效果如Path