如何在iOS8自定义键盘中弹出类似键盘的字符? [英] How to make popup like keyboard characters in iOS8 custom keyboard?
本文介绍了如何在iOS8自定义键盘中弹出类似键盘的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在iOS8自定义键盘中创建弹出窗口,如下图所示。
I want to create popup in iOS8 custom keyboard as shown below image.
有些代码正常工作但无法访问键盘的外窗并发生问题,如图所示在下面的图像-2
Some code are working but can't access outer window of keyboard and occures issue as shown in below image-2
推荐答案
这就是我在自定义键盘中所做的工作
This what i have done in my custom Keyboard its working
//adding pop up when character is tapped
- (void)addPopupToButton:(UIButton *)button
{
CGRect frame,frame1;
if(self.view.frame.size.width == 320)
{
//Keyboard is in Portrait
frame = CGRectMake(0, -25, 28, 43);
frame1=CGRectMake(0, 0, 28, 43);
}
else{
//Keyboard is in Landscape
frame = CGRectMake(3, -25, 35, 43);
frame1=CGRectMake(0, 10, 35, 43);
}
//create pop up view
UIView *popUp=[[UIView alloc]initWithFrame:frame];
//create a label to add to pop up view
UILabel *text = [[UILabel alloc] init];
//set frame for the label and set label title
[text setFrame:frame1];
[text setText:button.titleLabel.text];
text.textAlignment=NSTextAlignmentCenter;
[text setFont:[UIFont boldSystemFontOfSize:30]];
text.backgroundColor=[UIColor whiteColor];
//add label as popup view's subview
[popUp addSubview:text];
//add pop up view as button's subview
[button addSubview:popUp];
}
//remove Pop up view
-(void)endPopUpForButton:(UIButton*)button
{
if ([button subviews].count > 1)
{
[[[button subviews] objectAtIndex:1] removeFromSuperview];
}
}
这篇关于如何在iOS8自定义键盘中弹出类似键盘的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文