当我按下 nextButton 时,它是 UIBarButton。然后不执行相关操作。
UIButton *nextButton1=[UIButton buttonWithType:UIButtonTypeCustom];
[nextButton1 setBackgroundImage:[UIImage imageNamed:@"next.png"] forState:UIControlStateNormal];
[nextButton1 addTarget:self action:@selector(goToItems) forControlEvents:UIControlEventTouchUpOutside];
[nextButton1 sizeToFit];
UIBarButtonItem *nextButton=[[UIBarButtonItem alloc]initWithCustomView:nextButton1];
self.navigationItem.rightBarButtonItem=nextButton;
最佳答案
[nextButton1 addTarget:self action:@selector(goToItems) forControlEvents:UIControlEventTouchUpInside];
你传递的是UIControlEventTouchUpOutside
,应该是UIControlEventTouchUpInside
关于iphone - 按钮操作没有响应 iphone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11360548/