2012-10-03 137 views
0

我们如何在默认键盘中添加具有如下图所示界面的自定义按钮。如何自定义键盘

enter image description here

我怎么可以这样做?

谢谢。

+0

自定义键盘是一个很难的部分,因为苹果没有提供太多的工作。我会建议一个黑客,每当需要显示一个键盘显示按钮通过管理键盘通知的自定义视图。并以编程方式隐藏原始的。我不知道这是可以接受的appstore.Have第一次也检查 –

回答

0

它非常简单只需创建一个的viewController用的.xib并获得上述的画面截图。修复UIImageView的屏幕截图然后你需要放置自定义的UIButtons并设置标签属性与按钮意图相同1,2,3然后创建一个方法分配给所有UIButtons并使用它们的标签属性执行操作。

如果你想在UITextField中输入一些文本,那么你需要实现UITextFiled textShouldBeginEditing的委托方法返回no。你有什么想法?

-1

通过定制它们,您可以将简单的按钮添加到UIKeyBoard

- (void)keyboardDidShow:(NSNotification *)note { 


// create custom button 
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
doneButton.frame = CGRectMake(215, 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]; 

UIWindow* tempWindow; 

UIView* keyboard; 

for(int c = 0; c < [[[UIApplication sharedApplication] windows] count]; C++) 
{ 
    tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:c]; 

    for(int i = 0; i < [tempWindow.subviews count]; i++) 
    { 
     keyboard = [tempWindow.subviews objectAtIndex:i]; 

     if([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES) 
     { 
      [keyboard addSubview:doneButton]; 
     } 
    } 
} 
} 

或检查出此链接,自定义键盘布局

BSKeyboardControls

0

我想你可以提供一个UIView更换键盘......我从来没有使用但此功能。