实现功能:想通过后台捕获相关屏幕点击事件
硬件平台:iphone5c ios7.1.2
相关问题:执行这行代码void ioHIDEventSystem = IOHIDEventSystemClientCreate(kCFAllocatorDefault);报段错误,请帮忙分析一下,是什么原因?
详细代码如下:
#include <IOHIDEventSystem.h>
void handle_event (void target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event)
{
if (IOHIDEventGetType(event)==kIOHIDEventTypeDigitizer)
{
IOHIDFloat x=IOHIDEventGetFloatValue(event, (IOHIDEventField)kIOHIDEventFieldDigitizerX);
IOHIDFloat y=IOHIDEventGetFloatValue(event, (IOHIDEventField)kIOHIDEventFieldDigitizerY);
int width = [UIScreen mainScreen] bounds].size.width;
int height = [UIScreen mainScreen] bounds].size.height;
NSLog(@“click : %f, %f”, xwidth, yheight) ;
}
}
int main ()
{
printf(“111111111111111111111111111\n”);
sleep(3);
void *ioHIDEventSystem = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
printf(“2222222222222222222222222\n”);
IOHIDEventSystemClientScheduleWithRunLoop(ioHIDEventSystem, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
printf(“33333333333333333333333333\n”);
IOHIDEventSystemClientRegisterEventCallback(ioHIDEventSystem, handle_event, NULL, NULL);
CFRunLoopRun();
return 1;
}