我使用的 addTarget: action: forControlEvents 是这样的:
[ newsButton addTarget: self ]
Action:@selector (switchToNewsDetails)
ForControlEvents: UIControlEventTouchUpInside ] ;
我想传递参数到我的选择器“ switchToNewsDetails”。 我唯一成功做到的就是通过写下:
action:@selector(switchToNewsDetails:)
But I am trying to pass variables like integer values. Writing it this way doesn't work :
int i = 0;
[newsButton addTarget:self
action:@selector(switchToNewsDetails:i)
forControlEvents:UIControlEventTouchUpInside];
Writing it this way does not work either:
int i = 0;
[newsButton addTarget:self
action:@selector(switchToNewsDetails:i:)
forControlEvents:UIControlEventTouchUpInside];
Any help would be appreciated :)