如何将按钮图标添加到自定义键盘iOS 8? [英] How can I add button icons to custom keyboard iOS 8?

查看:78
本文介绍了如何将按钮图标添加到自定义键盘iOS 8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为ios 8创建自定义键盘。像这样创建键盘按钮

I am creating custom keyboard for ios 8. Creating keyboard buttons like this

    UIButton *aBtn = [ UIButton buttonWithType:UIButtonTypeCustom ];

    [aBtn setFrame:CGRectMake(x, 30, btnWidth, btnHeight)];

    [aBtn setImage:[UIImage imageNamed:@"A"] forState:UIControlStateNormal];

    [aBtn setTitle:@"A" forState:UIControlStateNormal];
    [aBtn setTitleColor:[ UIColor blackColor] forState:UIControlStateNormal];
    [aBtn setTitleColor:[ UIColor whiteColor] forState:UIControlStateHighlighted];
    [aBtn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:aBtn];

我的问题是图像没有设置为按钮。我该如何解决这个问题?

My problem is that the image is not set to button. How can I solve this?

我是否需要任何特殊步骤才能将图像添加到Xcode以获取自定义键盘?

Do I need any special steps to be able to add images to Xcode for custom keyboards?

推荐答案

您可能没有将图像添加到键盘目标。

You probably didn't add the image to your keyboard target.

检查键盘目标>构建阶段>复制捆绑资源以确保图像在那里。如果不是那么将它拖到那里。

Check your keyboard target > Build Phases > Copy bundle resources to make sure that the image is there. Drag it there if it isn't.

请注意,我说的是键盘目标,而不是主机应用程序。这可能是混乱。

Note that I am talking about the keyboard target, not the host app. That could be the confusion here.

这篇关于如何将按钮图标添加到自定义键盘iOS 8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆