什么是创建自定义键盘的最佳方法? [英] what is Best approach to create customize keypad?
问题描述
如何创建自定义字段的功能。
how can I create functionality of custom fields.
推荐答案
在转到git之前,尝试自己动手。
1.创建一个数组(仅限数字)的图像[1.img,2.img,3.png ......]或(仅限字母)图像数组[a.img,b .img,c.img。
2.lets说你只想数字。 (a)看看键盘视图,(b)运行循环一些类似的事情。在for循环中做这样的事情......
before going to git , try to do it on yourself. 1.create an array(numeric-only) of images[1.img, 2.img,3.png......] or (alphabetic-only) array of images [a.img, b.img, c.img. 2.lets say you want only numeric. (a)take a view say keypadView, (b)Run a loop some thing like .Do something like this in for loop...
for(i=0; i<numericArray.count;i++)
{
UIButton *numericKeyPadSingleButton=[[UIButton alloc]initWithFrame:CGRectMake(17+((i%3)*(104+5)), 67+(height*84), 104, 79)];
[numericKeyPadSingleButton setBackgroundImage:[UIImage imageNamed:[numericArray objectAtIndex:i]] forState:UIControlStateNormal];
[numericKeyPadSingleButton addTarget:self action:@selector(singleNumberClicked:) forControlEvents:UIControlEventTouchUpInside];
[numericKeyPadSingleButton setTag:i];
keypadView addSubiew:numericKeyPadSingleButton];
}
最后你也可以创建一个完成按钮。
} finaly you can create a Done button also.
然后你的singleNumberClicked看起来像这样:
then your singleNumberClicked looks like this:
-(void)singleNumberClicked:(id)sender
{
if ([sender tag] == 0) {
//1 clicked
}
否则if([sender tag] == 1){
else if ([sender tag] == 1) {
//2 clicked
}
}
你可以做到这一点男人试试你自己。
谢谢
you can do it man try your self. Thanks
这篇关于什么是创建自定义键盘的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!