具有多个参数的方法的选择器

时间:2010-11-15 10:30:42

标签: iphone selector uitoolbar

大家好我需要为这个方法编写选择器。我该怎么做?感谢名单!

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

以下是我需要它的代码:

UIBarButtonItem *deleteButton = [[UIBarButtonItem alloc]  initWithTitle:@"Delete User" style:UIBarButtonItemStyleBordered target:self action:@selector(my_button_click_here_is_need_a_selector:)];

[toolbar setItems:[NSArray arrayWithObjects: deleteButton, nil]];

1 个答案:

答案 0 :(得分:2)

请参阅How to pass method arguments to a selector,了解如何为该方法创建选择器(答案为@selector(tableView:cellForRowAtIndexPath:))。

但如果传递此选择器,则错误地使用-initWithTitle:…方法。 action的选择器必须是其中一种形式的回调

-(IBAction)clicked;
-(IBAction)clicked:(id)sender;
-(IBAction)clicked:(id)sender withEvent:(UIEvent*)event;

-tableView:cellForRowAtIndexPath:不属于上述情况。你应该为它编写一个特定的方法。

相关问题