我做了一个custom Keyboard app不久前在 iOS 9 上使用了表情符号。
我不太清楚我的代码出了什么问题,或者 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 actionselector(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 - iOS 10 后键盘扩展无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39613451/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |