gpt4 book ai didi

ios - 以编程方式添加UIButton时不可单击

转载 作者:行者123 更新时间:2023-12-01 19:48:09 25 4
gpt4 key购买 nike

我正在创建包含两个UIViewUILabel的自定义UIButton,因此我创建了一个子类来实现这一点。

现在,过程看起来像:

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
self.backgroundColor = [UIColor whiteColor];

self.settingsButton = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width - 2 * margin, frame.size.height - titleHeight - dateHeight, buttonSize, buttonSize)];
[self.settingsButton setImage:[UIImage imageNamed:@"settings_icon"] forState:UIControlStateNormal];
[self addSubview:self.settingsButton];

[self.settingsButton addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
return self;
}

按钮出现在UIView上,但不可单击。我试图设置 self.userInteractionEnabled = YES;和一些东西,但仍然没有结果:(

最佳答案

这是我有史以来最愚蠢的错误。透明的UINavigationBar阻止了触摸。

关于ios - 以编程方式添加UIButton时不可单击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47419146/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com