无文本框捕获文本输入 [英] Catch text input without textField

查看:234
本文介绍了无文本框捕获文本输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的利弊问题...
我正在开发iPad上的应用程序,我使用了采用蓝牙棒code读卡器。我已经与同步我的iPad吧code读卡器和我能赶上一个文本框文字没有问题。
当我读到一间酒吧code,我不想把它放在一个文本框,我要抓住它的一类,处理它,并决定用它做什么。我已经搜索在互联网上做到这一点的方式,但我不能找到它。有人能帮助我吗?我可以做一个类中的委托接收输入字符串?

Here a question for the pros... I'm developing an application on Ipad and i'm using a barcode reader with bluetooth. I have sync the barcode reader with my Ipad and I can catch the text on a textField without problems. When I read a barcode I don't want to put it on a textField, I want to catch it on a class, process it and decide what to do with it. I have searched on the internet the way to do it but I can't find it. Someone can help me? Can I do a class the delegate to receive the input strings?

我有点与它和任何帮助将失去对我非常有用的。

I'm a little lost with it and any help will be very usefull for me

感谢您的时间!

推荐答案

我已经解决了创建一个隐藏文本框是成为第一个响应者创建的ViewController时的问题。之后,我也做了同样的viewController该文本字段的委托。当BT codeBAR读者做一个读他让在最后一个返回,以便它调用 - (BOOL)textFieldShouldReturn:在那里我处理这些信息。我希望这将是有用的人用同样的问题未来的危机。我张贴code:

I have solved the problem creating a hide textfield that become the first responder when the viewcontroller is created. After I have did the same viewController the delegate of this text field. When the BT codebar reader do a read he makes a return at the end so it calls the - (BOOL)textFieldShouldReturn: where I process the information. I hope that will be usefull for someone in the futur with the same problem. I post the code:

_textSender = [[的UITextField页头] initWithFrame:方法CGRectMake(150,300,300,25);
    [_textSender setBackgroundColor:[的UIColor whiteColor]];
    [self.view addSubview:_textSender];
    _textSender.hidden = YES;
    [_textSender becomeFirstResponder]
    _textSender.delegate =自我;


- (BOOL)textFieldShouldReturn:(*的UITextField)文本框{
    [messageSenderProtocolDelegate消息:的TextField.text];
    返回YES;
}

这不是一个beatiful办法做到这一点,这让我有点小问题,当BT吧code断开键盘出现,这就是对我不好。我希望我没有键盘观点干净所有的时间。现在,当键盘显示了$ P $,我会,如果它是一个名为功能的研究pvent他是节目

It's not a beatiful way to do it and it gives me a little problem, when the BT barcode disconnects the keyboard appears and that's not good for me. I want my view clean without keyboards all the time. Now I will research if it's a function that is called when the keyboard shows to prevent him to be show

如果有人有这将是有用的任何意见,但说感谢您的帮助埃里克!

If someone have any advice it will be usefull but say thanks for your help Erik!

这篇关于无文本框捕获文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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