gpt4 book ai didi

iOS 点击动态 UIButton 崩溃

转载 作者:行者123 更新时间:2023-11-29 02:26:41 26 4
gpt4 key购买 nike

我正在以编程方式创建带有图像的 UIButton。

UIButton * bericht = [[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width- height, 0, height, height)];
[bericht setBackgroundImage:[UIImage imageNamed:@"bericht.png"] forState:UIControlStateNormal];
[bericht addTarget:self action:@selector(imageClicked:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:bericht];

- (void) imageClicked:(UIButton *) sender {
NSLog(@"test message");
}

当我点击这个按钮时,我收到了以下错误代码:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 
'-[__NSSetM goToFirstTrailer:]: unrecognized selector sent to instance 0x7fdaf1e73fe0'

有人知道解决办法吗?

最佳答案

将您的选择器方法更改为 imageClicked。

UIButton * bericht = [[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width- height, 0, height, height)];

[bericht setBackgroundImage:[UIImage imageNamed:@"bericht.png"] forState:UIControlStateNormal];
[bericht addTarget:self action:@selector(imageClicked:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:bericht];

- (void) imageClicked:(UIButton *) sender {
NSLog(@"iaksdkjas");
}

关于iOS 点击动态 UIButton 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27442606/

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