前段时间我用emojis为iOS 9制作了custom Keyboard app。
我无法弄清楚我的代码出了什么问题或者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];
}
编辑:仍然没有运气,有什么帮助?