2010-11-15 47 views
0

大家好,我需要爲此方法編寫選擇器。我該怎麼做?感謝名單!選擇器的方法有多個參數

- (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]]; 

回答

2

參見如何創建該方法的選擇(答案是@selector(tableView:cellForRowAtIndexPath:)How to pass method arguments to a selector

但是,如果您通過此選擇器,您正在錯誤地使用-initWithTitle:…方法。所述action的選擇必須在形式

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

-tableView:cellForRowAtIndexPath:的是沒有以上的一個回調。你應該爲它編寫一個特定的方法。

相關問題