Questions tagged «uicontrolevents»

13
将参数传递给addTarget:action:forControlEvents
我正在使用addTarget:action:forControlEvents这样的: [newsButton addTarget:self action:@selector(switchToNewsDetails) forControlEvents:UIControlEventTouchUpInside]; 并且我想将参数传递给选择器“ switchToNewsDetails”。我唯一成功完成的事情是通过编写(id)sender来传递: action:@selector(switchToNewsDetails:) 但是我试图传递像整数值这样的变量。用这种方式写不起作用: int i = 0; [newsButton addTarget:self action:@selector(switchToNewsDetails:i) forControlEvents:UIControlEventTouchUpInside]; 用这种方式编写也不起作用: int i = 0; [newsButton addTarget:self action:@selector(switchToNewsDetails:i:) forControlEvents:UIControlEventTouchUpInside]; 任何帮助,将不胜感激 :)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.