zoukankan      html  css  js  c++  java
  • ios定制键盘

    注册键盘弹出消息:

    [[NSNotificationCenter defaultCenter] addObserver:self 
    selector:@selector(keyboardWillShow:)
    name:UIKeyboardWillShowNotification
    object:nil];
    移除注册:
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    获取键盘VIEW并添加自己的BUTTON:
    - (void)keyboardWillShow:(NSNotification *)note {  
    // create custom button
    UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
    doneButton.frame = CGRectMake(0, 163, 106, 53);
    doneButton.adjustsImageWhenHighlighted = NO;
    [doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
    [doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
    [doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];

    // locate keyboard view
    UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
    UIView* keyboard;
    for(int i=0; i<[tempWindow.subviews count]; i++) {
    keyboard = [tempWindow.subviews objectAtIndex:i];
    // keyboard view found; add the custom button to it
    if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
    [keyboard addSubview:doneButton];
    }
    }

    http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key

  • 相关阅读:
    用两个栈实现队列
    *重建二叉树
    *链表中环的入口结点
    *复杂链表的复制
    替换空格
    python多线程文件拷贝
    进程、线程、协程
    文件处理工具sed、awk
    CentOs软件安装
    python logging模块
  • 原文地址:https://www.cnblogs.com/ligun123/p/2223584.html
Copyright © 2011-2022 走看看