在 uitextview 之间移动
经过几次尝试,我决定写下来,因为我就是不知道如何让它发挥作用。我指的是填字游戏。 我所做的是这样的:
- (void) viewDidLoad{
int move = 15;
int h = 50;
for (int i = 0; i < 416; i++){
move = move + 36;
fieldUno = [[UITextField alloc] init];
fieldUno.tag = i;
[fieldUno viewWithTag:i].frame = CGRectMake(move, h, 35, 35);
[fieldUno setBackgroundColor:[UIColor purpleColor]];
[fieldUno setTextAlignment:UITextAlignmentCenter];
[fieldUno setFont:[UIFont fontWithName:@"Times New Roman" size:30]];
[fieldUno setDelegate:self];
[self.view addSubview:[fieldUno viewWithTag:i]];
[fieldUno release];
if (i == 25) h = h + 36, move = 15;
if (i == 51) h = h + 36, move = 15;
if (i == 77) h = h + 36, move = 15;
if (i == 103) h = h + 36, move = 15;
if (i == 129) h = h + 36, move = 15;
if (i == 155) h = h + 36, move = 15;
if (i == 181) h = h + 36, move = 15;
if (i == 207) h = h + 36, move = 15;
if (i == 233) h = h + 36, move = 15;
if (i == 259) h = h + 36, move = 15;
if (i == 285) h = h + 36, move = 15;
if (i == 311) h = h + 36, move = 15;
if (i == 337) h = h + 36, move = 15;
if (i == 363) h = h + 36, move = 15;
if (i == 389) h = h + 36, move = 15;
但现在我不知道如何使用BecomeFirstResponder 进行阅读中的下一个。我想做一些非常简单的事情,您只能选择第一个文本框。然后检查两个不同的数组,看看结果是否错误,但这已经容易多了。
我应该调用什么方法?例如,如果标签 1 到标签 5 是一个单词,而标签另一个 7 到 12,我将不得不为每个字段做不同的操作?如果我要竖写呢?我不知道我是否走在正确的轨道上,有人建议我使用绘制矩形,但我会遵循这种方式,
如果代码有点混乱,我深表歉意。
我不知道还能怎么办
After several attempts, I decided to write because I just can not figure out how to make it work. I refer to the crossword puzzle.
what I did is this:
- (void) viewDidLoad{
int move = 15;
int h = 50;
for (int i = 0; i < 416; i++){
move = move + 36;
fieldUno = [[UITextField alloc] init];
fieldUno.tag = i;
[fieldUno viewWithTag:i].frame = CGRectMake(move, h, 35, 35);
[fieldUno setBackgroundColor:[UIColor purpleColor]];
[fieldUno setTextAlignment:UITextAlignmentCenter];
[fieldUno setFont:[UIFont fontWithName:@"Times New Roman" size:30]];
[fieldUno setDelegate:self];
[self.view addSubview:[fieldUno viewWithTag:i]];
[fieldUno release];
if (i == 25) h = h + 36, move = 15;
if (i == 51) h = h + 36, move = 15;
if (i == 77) h = h + 36, move = 15;
if (i == 103) h = h + 36, move = 15;
if (i == 129) h = h + 36, move = 15;
if (i == 155) h = h + 36, move = 15;
if (i == 181) h = h + 36, move = 15;
if (i == 207) h = h + 36, move = 15;
if (i == 233) h = h + 36, move = 15;
if (i == 259) h = h + 36, move = 15;
if (i == 285) h = h + 36, move = 15;
if (i == 311) h = h + 36, move = 15;
if (i == 337) h = h + 36, move = 15;
if (i == 363) h = h + 36, move = 15;
if (i == 389) h = h + 36, move = 15;
but now I do not know how to make the next one in reading, with becomeFirstResponder. I wanted to do something quite simple and you can select only the first text box. then do a check on two different arrays to see if the result is wrong or not, but this is already much easier.
what methods should I call? think for example if the tag 1 to tag 5 will be a word, and tag another 7 to 12, I will have to do different if, for each field? and if I were to write vertically? I do not know if I'm on the right track, I was advised to use draw rect but I would follow this way
I apologize if the code is a little messed up.
I did not know how else to do
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太确定你在问什么,但无论如何我都会尽力回答。您可以将
[nextTextFieldBecomeFirstResponder];
添加到委托方法textFieldDidEndEditing
中,该方法将用户带到您认为他接下来应该位于的任何文本字段。I'm not completely certain what you're asking, but I'll take a stab at answering anyway. You can add
[nextTextField becomeFirstResponder];
to the delegate methodtextFieldDidEndEditing
that takes the user to whichever textField you think he should be at next.