似乎是一件容易的事。工具栏内的按钮(在键盘顶部)应该将发送者发送到函数。使用下面的代码,我在调试器中收到“发送到实例的无法识别的选择器”。
我的目标是访问自定义单元格的特定 TextField。该代码非常适合识别例如开关
工具栏声明:
UIToolbar* itemToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
itemToolbar.barStyle = UIBarStyleBlackTranslucent;
itemToolbar.items = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelNumberPad)],
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc]initWithTitle:@"Save" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)],
nil];
[itemToolbar sizeToFit];
doneWithNumberPad 的功能:
- (void)doneWithNumberPad:(id)sender {
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonPosition];
NSManagedObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSLog(@"%@", [object valueForKey:@"item"]);
}
谢谢你的帮助