Zhe*_*hen 3 objective-c uibutton uiview ios
我创建了一个名为的类UICustomButton,它是一个子类UIView.我添加了一个UIButton以UIView作为subview在下面我的代码如下所示:
-(id)initWithButtonType:(NSString *)type
{
self = [super init];
if (self)
{
self.customButton = [self setupButtonWithTitle:type andFrame:frame];
[self addSubview:self.customButton];
self.customButton addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
我面临的问题是,虽然按钮出现,但它们不可点击.我添加按钮的方式有什么问题UIView吗?

编辑:要添加,我将这个自定义按钮类实例用于单元格:
UICustomButton *customButton = [[UICustomButton alloc]initWithFrame:someFrame];
[cell.contentView addSubView:customButton];
Run Code Online (Sandbox Code Playgroud)
小智 8
检查UICustomButton对象的框架,如果self.customButton超出它的框架superView.
| 归档时间: |
|
| 查看次数: |
10817 次 |
| 最近记录: |