键盘上面加一个工具栏

来源:互联网 发布:itunes如何安装软件 编辑:程序博客网 时间:2024/04/29 03:16


重写代理的inputAccessoryView

-(UIView *)inputAccessoryView{
    UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, boundsWidth, 44)];
    UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
    UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithTitle:LocalString(@"确定") style:UIBarButtonItemStylePlain target:self action:@selector(doIt)];
    toolBar.items = [NSArray arrayWithObjects:flexSpace,rightButtonItem, nil];
    return toolBar;
}
-(void)doIt
{
    [taskMoneyCell.contentTextField resignFirstResponder];
}

0 0