小编fre*_*rdo的帖子

采用UIKeyInput协议从蓝牙键盘获取输入

我有一个蓝牙脚踏开关,基本上是一个无线键盘.一个踏板发送向上箭头键,另一个发送向下箭头键.我希望能够在我的iPad应用程序中按下其中一个踏板时执行我自己的代码.踏板的制造者告诉我应该创建一个UITextField,并UIKeyInput在包含UIView中采用协议并使用beginningOfDocumentendOfDocument方法来执行我的代码.我这样做了,但不管我做什么,都不会调用UIKeyInput或UITextInput方法.任何人都可以引导我完成这个,或者指导我学习与此相似的教程吗?有更简单的方法吗?

谢谢你的帮助.

这是我的.h:

#import <UIKit/UIKit.h>

@interface Pedal_ProtocolViewController : UIViewController <UIKeyInput, UITextInput>{
UITextField *myTextField;
}
@property (nonatomic, retain) IBOutlet UITextField *myTextField;
@end
Run Code Online (Sandbox Code Playgroud)

这是我的.m:

#import "Pedal_ProtocolViewController.h"

@implementation Pedal_ProtocolViewController

@synthesize myTextField;

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

// Implement viewDidLoad to do additional …
Run Code Online (Sandbox Code Playgroud)

subclass objective-c ipad ios

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

ios ×1

ipad ×1

objective-c ×1

subclass ×1