iOS 10后键盘扩展无法正常工作

时间:2016-09-21 10:05:01

标签: ios iphone xcode custom-keyboard

前段时间我用emojis为iOS 9制作了custom Keyboard app

iOS 10问世后,它停止工作,现在只加载底部视图。 enter image description here

我无法弄清楚我的代码出了什么问题或者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];

}

编辑:仍然没有运气,有什么帮助?

1 个答案:

答案 0 :(得分:2)

我通过设置一个新的高度约束来解决它。万一它可以帮助任何有同样问题的人。我尝试了很多我找到的答案但是对我有用。

enter image description here