gpt4 book ai didi

ios - 如何在 iOS8 自定义键盘中像键盘字符一样弹出?

转载 作者:IT王子 更新时间:2023-10-29 08:20:27 25 4
gpt4 key购买 nike

我想在 iOS8 自定义键盘中创建弹出窗口,如下图所示。

Want to create this type of keyboard in iOS8

某些代码可以正常工作,但无法访问键盘的外部窗口并出现如下图 2 所示的问题

Issue in iOS8 Custom Keyboard

最佳答案

这是我在我的自定义键盘中所做的工作

//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];
}
}

enter image description here

关于ios - 如何在 iOS8 自定义键盘中像键盘字符一样弹出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25377846/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com