设置键盘顶部显示的工具条

- (void)createKeyboardTool
{
    keyboardTool = [[UIToolbar alloc] initWithFrame: CGRectMake(kZero, kZero, kScreenW, 44.0f)];
    NSMutableArray *myToolBarItems = [NSMutableArray array];
  //创建键盘工具条上面的按钮,并设置点击事件
    UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(cancelAction)];
    UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(saveAction)];
    UIBarButtonItem *saveBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(saveAction)];

    [myToolBarItems addObject:cancelBtn];
    [myToolBarItems addObject:space];
    [myToolBarItems addObject:saveBtn];
    keyboardTool.items = myToolBarItems;
}
    //inputAccessoryView:设置键盘顶部显示的工具条;inputView:自定义键盘    commentTextView = [[UITextView alloc]initWithFrame:CGRectMake(kZero, kZero, kScreenW, 200)];
    [commentTextView becomeFirstResponder];
    commentTextView.inputAccessoryView = keyboardTool;

设置键盘顶部显示的工具条

时间: 2024-08-25 10:11:54

设置键盘顶部显示的工具条的相关文章

034在屏幕中显示一个工具条

效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UIViewController 4 @end ViewController.m 1 #import "ViewController.h" 2 3 @interface ViewController () 4 - (void)nextDidPush; 5 @end 6 7 @implementation ViewC

SWIFT显示底部的工具条

有以下页面显示我的讯息,用户可以点击右上角的编辑按钮进入删除状态.点击编辑按钮后,按钮文字改为“取消”,左上角的按钮变为“全选”,同时显示底部工具条带有“删除”按钮 实现起来挺简单的,在正常状态下点击编辑按钮的方法内写入: self.navigationController?.setToolbarHidden(false, animated: true) var btnDelete = UIBarButtonItem(title: "删除", style: UIBarButtonIte

给键盘添加一个工具条

开发中经常遇到要给键盘添加一个工具条,工具条上有按钮,点击后可以隐藏键盘的情况.比如下面:需要弹出纯数字键盘,这个时候就需要通过工具条来隐藏键盘了. 场景:点击一个cell中的textfield弹出数字键盘,上面加上工具条 步骤1:在cellforrow中创建工具条. 步骤2:把textfield的inputAccessoryView 属性 = 你创建的工具条 步骤3:把textfield的keyboradType 属性 =  UIKeyboardTypeNumberPad 步骤4:实现工具条中

iOS开发项目篇—29自定义工具条

iOS开发项目篇—29自定义工具条 一.简单说明 1.实现效果: 2.实现思路: (1)尝试: 1 //添加子控件 2 -(void)setupTextView 3 { 4 //1.创建输入控件 5 YYTextView *textView=[[YYTextView alloc]init]; 6 //设置frame 7 textView.frame=self.view.bounds; 8 [self.view addSubview:textView]; 9 self.textView=textV

新浪微博客户端(38)-显示键盘上的工具条

DJComposeToolbar.m #import "DJComposeToolbar.h" @implementation DJComposeToolbar - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNa

iOS_22自定义键盘工具条

最终效果图: Main.storyboard KeyboardTool.xib KeyboardTool.h // KeyboardTool.h // 键盘处理 // Created by beyond on 14-8-24. // Copyright (c) 2014年 com.beyond. All rights reserved. #import <UIKit/UIKit.h> @protocol KeyboardToolDelegate; typedef enum { kKeyboar

iOS开发——Swift实战篇&amp;通知之键盘的现实与隐藏(加键盘工具条)

看这篇文章之前,建议读者先了解一下通知NSNotifation的通信原理 不好描述,我先上图: 就是点击“完成”可以隐藏键盘和自己,键盘出来时他们也跟着出来,对,就是这种效果,非常常用 1,设置keyboardHeaderview和“完成”(这里的self.keyboardHeaderView设置成了self对象) 1 self.keyboardHeaderView.frame = CGRect(x: 0,y: DeviceFrame.height+StatusBarFrame.height,w

MFC文档应用程序CToolBar:设置两个工具条并列停靠到同一条边上 转

转自:http://blog.csdn.net/panshiqu/article/details/9369891# 将多个工具条同时并列停靠在某窗口的某一条边上.对于这种停靠方法,利用上述工具条控制函数DockControlBar的lpRect参数,通过控制工具条的停靠矩形区域的方法可以实现 1:在MainFrm.h中增加如下成员函数定义 // 增加 public: void DockControlBarLeftOf(CToolBar* bar, CToolBar* leftof); . 2:在

CAD隐藏或显示工具条上的按钮(com接口VB语言)

主要用到函数说明: MxDrawXCustomFunction::Mx_HideToolBarControl 隐藏或显示工具条上的按钮.详细说明如下: 参数 说明 IN LPCTSTR pszToolBarName 工条名称 IN LPCTSTR pszControlName = NULL 按钮名称,多个按钮名称,可以用逗号分隔开,为空,隐藏或显示所有按钮 IN BOOL isHide = TRUE 是否隐藏按钮 IN BOOL isAutoRecalcLayout = TRUE 是否自动重新布