2
A
回答
1
通过为UIResponder
实施inputAccessoryView
来添加按钮。
1
我所做的是从零开始创建一个键盘。使用两个UIViews
以及位于底部的Fist视图中的按钮。设置用户交互这些按钮关闭,然后用此验证码:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:keyboardView];
//here loops all labels
for(UIButton *keyButton in keyboardView.subviews){
if (CGRectContainsPoint(keyButton.frame,touchPoint)&&keyButton.enabled) {
keyButton.highlighted = YES;
for(UIButton *bigKey in keyboardTextView.subviews){
if (bigKey.currentTitle==keyButton.currentTitle) {
bigKey.hidden=NO;
}
else{
bigKey.hidden=YES;
}
}
}
else if(!CGRectContainsPoint(keyButton.frame,touchPoint)){
keyButton.highlighted = NO;
}
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:keyboardView];
//here loops all labels
for(UIButton *keyButton in keyboardView.subviews){
if (CGRectContainsPoint(keyButton.frame,touchPoint)&&keyButton.enabled) {
keyButton.highlighted = YES;
for(UIButton *bigKey in keyboardTextView.subviews){
if (bigKey.currentTitle==keyButton.currentTitle) {
bigKey.hidden=NO;
}
else{
bigKey.hidden=YES;
}
}
}
else if(!CGRectContainsPoint(keyButton.frame,touchPoint)){
keyButton.highlighted = NO;
}
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:keyboardView];
for(UIButton *keyButton in keyboardView.subviews){
keyButton.highlighted = NO;
if(CGRectContainsPoint(keyButton.frame,touchPoint) && keyButton.enabled == YES){
keyButton.enabled = NO;
letterUsedString=keyButton.currentTitle;
// right here you can use the letter Used String.
}
}
for(UIButton *bigKey in keyboardTextView.subviews){
bigKey.hidden=YES;
}
}
所有你需要的是二IBOutlets
的意见,keyboardTextView
和键盘查看。我将上传一些文件,以便您可以看到我的键盘。所以第一个视图是你按下的按钮,一个按钮背景中的图像。第二个视图是突出显示的按钮。如果您实现该代码并连接两个IBOutlets
,它将像键盘一样工作。任何未被识别的变量只会添加到您的.h
。当我的按钮,其中按下我强调他们从改变形象:
到:
然后我上面的图像放大按钮即可:
只需将你的按钮放在你想要的位置,上面的放大按钮。放大的按钮视图是可见的,但所有按钮内部都隐藏,直到您按下。我希望我的代码能够帮助你,你必须自己做故事板。
相关问题
- 1. 如何将自定义按钮添加到键盘?
- 2. 如何将我的自定义键添加到键盘?
- 3. 自定义按钮添加到数字键盘的问题
- 4. 如何将按钮图标添加到自定义键盘iOS 8?
- 5. 如何在iOS中将自定义按钮添加到iPhone键盘?
- 6. 如何将自定义键添加到ios中的键盘?
- 7. 添加自定义按钮到数字键盘的键盘ios 6
- 8. 如何将自定义键盘快捷键添加到GWT CellTable
- 9. 将按钮添加到软键盘
- 10. 自定义键盘 - 长按键盘按钮时添加多个表情符号
- 11. 将自定义按钮添加到SlickGrid?
- 12. 将自定义按钮添加到Galleria
- 13. 如何将inputAccessoryView添加到自定义键盘(ios扩展)
- 14. 在自定义键盘中添加下一个按钮
- 15. 我可以将自定义键盘添加到核心键盘吗?
- 16. 如何制作按钮按钮类型(自定义键盘)
- 17. 如何将完成的按钮添加到键盘
- 18. 将我自己的自定义键盘添加到特定的编辑文本
- 19. 如何在默认Android键盘中添加按键/自定义按键
- 20. 如何隐藏我添加到UITabBar的自定义按钮?
- 21. iOS键盘和自定义按钮
- 22. 自定义键盘退格按钮
- 23. 如何将“.com”按钮添加到Android键盘?
- 24. 如何将按钮添加到Android软键盘?
- 25. 将自定义样式添加到QTableview中添加的按钮
- 26. 如何将自定义按钮添加到气球android-mapviewbaloons中?
- 27. 如何将按钮添加到自定义视图?
- 28. 如何将自定义按钮添加到UIAlertView?
- 29. 如何将自定义按钮添加到管理列表中?
- 30. 如何将披露按钮添加到自定义UITableViewCell
Thx为您的文章,我用谷歌,并找到了这个教程:http://gabriel-tips.blogspot.de/2011/05/input-accessory-view-how-to-add-extra.html –