2

我将使用 libactivator 在我的应用程序中创建控制机制。但它在 iOS5.x 中不起作用,而在 iOS6.x 中运行良好。在我的测试代码中,它会在receiveEvent(默认为libactivator.volume.up.press)时弹出一个提示提示。这在iOS6.x中有效,但在iOS5.x中无效。没有任何错误,只是没有效果,并且在 Activator 的设置视图中没有此应用程序的设置选项。

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <libactivator/libactivator.h>


@interface TestActivator : NSObject<LAListener> {
}
@end

@implementation TestActivator



- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event
{

    UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"TestActivator" message:[event name] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [av show];
    [av release];
    [event setHandled:YES];
}

+ (void)load
{
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        NSString * packID = @"com.example.TestActivator";


        [[LAActivator sharedInstance] registerListener:[self new] forName:packID];
        [[LAActivator sharedInstance] assignEvent:[LAEvent eventWithName:@"libactivator.volume.up.press"] toListenerWithName:packID];

        [pool release];
}

@end
4

0 回答 0