iOS 10 后键盘扩展无法正常工作
Keyboard Extension not working properly after iOS 10
我前段时间为 iOS 9.
用表情符号制作了一个 custom Keyboard app
iOS10出来后就停止工作了,现在只加载底部视图。
我不太明白我的代码有什么问题或 iOS 有什么变化 10,我过去几天在网上搜索但找不到任何有用的东西
这是加载表情符号的代码
- (void)loadNthEmoji{
[self.keyboard.imvFavorite setBackgroundImage:[UIImage imageNamed:@"btn_favorite"] forState:UIControlStateNormal];
NSInteger nTag = [defaults integerForKey:@"EMOJI_FACE_EMOJI_KIND"];
if (nTag == 0)nTag = 1;
[self setAlpha:nTag];
[self removeSubViewFromEmojiView];
CGRect rectWrapper = self.keyboard.scvEmojis.frame;
CGFloat fSpace = 4;
NSInteger nEmojiRow = 3;
CGFloat fHeight = ((rectWrapper.size.height - (nEmojiRow + 1) * fSpace) / nEmojiRow);
CGFloat fWidth = fHeight;
NSInteger nCount = [[arrCounts objectAtIndex:nTag]integerValue];
for (NSInteger i = 0 ; i < nCount; i ++){
NSInteger nRow = i % nEmojiRow;
NSInteger nColumn = i / nEmojiRow;
CGRect rectFrame = CGRectMake(fSpace + (fSpace + fWidth) * nColumn, fSpace + (fSpace + fHeight) * nRow, fWidth/1.3, fHeight/1.3);
UIImageView *imvEmoji = [[UIImageView alloc]initWithFrame:rectFrame];
imvEmoji.contentMode = UIViewContentModeScaleAspectFit;
imvEmoji.tag = 10000 * nTag + i;
[imvEmoji setImage:[UIImage imageNamed:[NSString stringWithFormat:@"ec%i (%i).png", (int)nTag, (int)i + 1]]];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tabEmoji:)];
[imvEmoji setUserInteractionEnabled:YES];
[imvEmoji addGestureRecognizer:tapGesture];
[self.keyboard.scvEmojis addSubview:imvEmoji];
}
[self.keyboard.scvEmojis setContentSize:CGSizeMake(fSpace + (fSpace + fWidth) * ((int)(nCount / nEmojiRow) + (nCount % nEmojiRow == 0 ? 0 : 1)), rectWrapper.size.height)];
[activityIndicatorView stopAnimating];
[self.keyboard.viewEmoji setHidden:NO];
}
编辑:还是不行,有什么帮助吗?
我通过设置新的高度限制解决了这个问题。万一它可以帮助任何遇到同样问题的人。我尝试了很多我找到的答案,但对我有用。
我前段时间为 iOS 9.
用表情符号制作了一个 custom Keyboard appiOS10出来后就停止工作了,现在只加载底部视图。
我不太明白我的代码有什么问题或 iOS 有什么变化 10,我过去几天在网上搜索但找不到任何有用的东西
这是加载表情符号的代码
- (void)loadNthEmoji{
[self.keyboard.imvFavorite setBackgroundImage:[UIImage imageNamed:@"btn_favorite"] forState:UIControlStateNormal];
NSInteger nTag = [defaults integerForKey:@"EMOJI_FACE_EMOJI_KIND"];
if (nTag == 0)nTag = 1;
[self setAlpha:nTag];
[self removeSubViewFromEmojiView];
CGRect rectWrapper = self.keyboard.scvEmojis.frame;
CGFloat fSpace = 4;
NSInteger nEmojiRow = 3;
CGFloat fHeight = ((rectWrapper.size.height - (nEmojiRow + 1) * fSpace) / nEmojiRow);
CGFloat fWidth = fHeight;
NSInteger nCount = [[arrCounts objectAtIndex:nTag]integerValue];
for (NSInteger i = 0 ; i < nCount; i ++){
NSInteger nRow = i % nEmojiRow;
NSInteger nColumn = i / nEmojiRow;
CGRect rectFrame = CGRectMake(fSpace + (fSpace + fWidth) * nColumn, fSpace + (fSpace + fHeight) * nRow, fWidth/1.3, fHeight/1.3);
UIImageView *imvEmoji = [[UIImageView alloc]initWithFrame:rectFrame];
imvEmoji.contentMode = UIViewContentModeScaleAspectFit;
imvEmoji.tag = 10000 * nTag + i;
[imvEmoji setImage:[UIImage imageNamed:[NSString stringWithFormat:@"ec%i (%i).png", (int)nTag, (int)i + 1]]];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tabEmoji:)];
[imvEmoji setUserInteractionEnabled:YES];
[imvEmoji addGestureRecognizer:tapGesture];
[self.keyboard.scvEmojis addSubview:imvEmoji];
}
[self.keyboard.scvEmojis setContentSize:CGSizeMake(fSpace + (fSpace + fWidth) * ((int)(nCount / nEmojiRow) + (nCount % nEmojiRow == 0 ? 0 : 1)), rectWrapper.size.height)];
[activityIndicatorView stopAnimating];
[self.keyboard.viewEmoji setHidden:NO];
}
编辑:还是不行,有什么帮助吗?
我通过设置新的高度限制解决了这个问题。万一它可以帮助任何遇到同样问题的人。我尝试了很多我找到的答案,但对我有用。