ios - 如何使 UITableViewCell 笔尖配件工作?
问题描述
我想在我的自定义 UITableViewCell 上使用一个附件,但不幸的是我不知道该怎么做。我尝试制作一个插座,但线路没有连接到任何地方(尽管单元格选择了自定义类)。
这是笔尖的标题:
#import "UIKit/UIKit.h"
@interface CustomCreditCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *profileName;
@property (weak, nonatomic) IBOutlet UILabel *ccNumber;
@end
这是细胞类:
#import "CustomCreditCell.h"
@interface CustomCreditCell()
@end
@implementation CustomCreditCell
@end
解决方案
在您的头文件中,您通常会放置一个插座来引用您拖动到单元格的 IB 视图层次结构中的按钮。然后,您可以从 IB 中的单元类 ctrl 拖动到按钮上以连接插座。
@property (nonatomic, weak) IBOutlet UIButton *infoButton;
您还可以在单元类中创建一个操作,以便在单击按钮时接收消息:
- (IBAction) handleInfoButtonClick: (id) sender {
/* do click here */
}
并 ctrl 从按钮拖动到 IB 中的单元格以指示按钮将调用什么操作。
对于将代码连接到界面元素的初学者教程,您可以参考 Apple 的入门教程:
推荐阅读
- jquery - 在 iframe 中获取 Visio SharePoint WebPart 的 css
- python - Python:如何按小时和天对熊猫数据框进行分组?
- python - Seaborn 内核密度估计,但带有值
- nginx - Poste.io 的 Nginx 反向代理
- javascript - innerHTML 模板添加的功能自动触发
- python - 在熊猫中计算具有多个条件的行
- electron - 如何在电子中实现延迟深度链接
- python - 广播 4D numpy 数组
- python - 比python中的两个for循环(嵌套)更好的方法
- android - 复制的 Android Studio 项目无法重构,因为它们是链接的