gpt4 book ai didi

iPhone 按下按钮时出现错误

转载 作者:行者123 更新时间:2023-12-03 21:12:49 25 4
gpt4 key购买 nike

按下按钮时,我收到下面显示的错误消息。我的“buttonPressed”方法中还没有任何代码,尽管我认为这与它没有任何关系?

错误消息:“抛出“NSException”实例后调用终止程序收到信号:“SIGABRT”。

UIButton * myButton = [UIButton buttonWithType:UIButtonTypeCustom];

[myButton setImage:[UIImage imageNamed:@"ButtonStandard.png"] forState:UIControlStateNormal]; [myButton setImage:[UIImage imageNamed:@"ButtonSelected.png"] forState:UIControlStateSelected]; [myButton setShowsTouchWhenHighlighted:YES];

myButton.frame = CGRectMake(0.0, 380.0, 320.0, 100.0);
[myButton addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
[contentView addSubview:myButton];

任何帮助都会很棒。

最佳答案

@selector(buttonPressed)更改为@selector(buttonPressed:)(注意末尾的冒号)并将方法本身更改为:

-(void)buttonPressed:(id)sender {
/* sender will be the UIButton. */
}

关于iPhone 按下按钮时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2017475/

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