iPhone如何模拟触屏事件,输入等事件

怎么模拟发送一个触摸屏点击事件给iphone系统_百度知道
怎么模拟发送一个触摸屏点击事件给iphone系统
我有更好的答案
iPhone触摸屏一般是不会刮花的主要是背面和四周的金属框,一般爱惜的人都会去买一个套套,把它套以来.当然也有些无所谓的人就不会去把他套起来.
设置,通用,辅助功能,有个a什么的英文的那个就是,打开开好了
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。没有更多推荐了,
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!博客分类:
http://blog.csdn.net/guojin08/article/details/
iOS私有头文件:
https://github.com/kennytm/iphone-private-frameworks
iOS 6.0模拟器的私有库路径:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/System/Library/PrivateFrameworks
真机iOS7.1系统的私有库路径:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/PrivateFrameworks
iPod-5.1.1的私有库路径:
/Users/tangwu/Library/Developer/Xcode/iOS DeviceSupport/5.1.1 (9B206)/Symbols/System/Library/PrivateFrameworks
#include &mach/mach_time.h&
#import &objc/message.h&
#import &dlfcn.h&
#import "SsjjSyViewController.h"
#import "GraphicsServices.h"
#import "GraphicsServices.h"
#define SBSERVPATH
"/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices"
@interface SsjjSyViewController ()
static mach_port_t getFrontMostAppPort() {
mach_port_t *
void *lib = dlopen(SBSERVPATH, RTLD_LAZY);
int (*SBSSpringBoardServerPort)() = dlsym(lib, "SBSSpringBoardServerPort");
port = (mach_port_t *)SBSSpringBoardServerPort();
dlclose(lib);
void *(*SBFrontmostApplicationDisplayIdentifier)(mach_port_t *port, char *result) = dlsym(lib, "SBFrontmostApplicationDisplayIdentifier");
char appId[256];
memset(appId, 0, sizeof(appId));
SBFrontmostApplicationDisplayIdentifier(port, appId);
return GSCopyPurpleNamedPort(appId);
@implementation SsjjSyViewController
- (void)sendTap : (CGPoint) point{
[self sendTouchStart:point];
[self sendTouchEnd:point];
- (void)sendTouchStart: (CGPoint) point{
[self sendEventForPhase:UITouchPhaseBegan point:point];
- (void)sendTouchEnd: (CGPoint) point{
[self sendEventForPhase:UITouchPhaseEnded point:point];
- (void)sendEventForPhase: (UITouchPhase)phase
point : (CGPoint) point{
CGPoint adjustedPoint = [self.view convertPoint:point toView:self.view.window];
NSLog(@"point : %@ \n NSStringFromCGPoint(adjustedPoint: %@ \n", NSStringFromCGPoint(point), NSStringFromCGPoint(adjustedPoint));
uint8_t touchEvent[sizeof(GSEventRecord) + sizeof(GSHandInfo) + sizeof(GSPathInfo)];
struct GSTouchEvent {
GSHandInfo
} * event = (struct GSTouchEvent*) &touchE
bzero(event, sizeof(event));
event-&record.type = kGSEventH
event-&record.subtype = kGSEventSubTypeU
event-&record.location =
event-&record.timestamp = GSCurrentEventTimestamp();
event-&record.infoSize = sizeof(GSHandInfo) + sizeof(GSPathInfo);
event-&handInfo.type = (phase == UITouchPhaseBegan) ? kGSHandInfoTypeTouchDown : kGSHandInfoTypeTouchUp;
event-&handInfo.pathInfosCount = 1;
bzero(&event-&handInfo.pathInfos[0], sizeof(GSPathInfo));
event-&handInfo.pathInfos[0].pathIndex
event-&handInfo.pathInfos[0].pathIdentity
event-&handInfo.pathInfos[0].pathProximity = (phase == UITouchPhaseBegan) ? 0x03 : 0x00;
event-&handInfo.pathInfos[0].pathLocation
= adjustedP
mach_port_t port = getFrontMostAppPort();
GSEventRecord* record = (GSEventRecord*)
record-&timestamp = GSCurrentEventTimestamp();
GSSendEvent(record, port);
- (void)viewDidLoad
[super viewDidLoad];
*btn1 = [[UIButton alloc] initWithFrame:CGRectMake(40, 40, 200, 100)];
[btn1 setTitle:@"按钮1" forState:UIControlStateNormal];
[btn1 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
[btn1 addTarget:self action:@selector(btn1TouchDown:) forControlEvents:UIControlEventTouchDown];
[btn1 addTarget:self action:@selector(btn1TouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn1];
*btn2 = [[UIButton alloc] initWithFrame:CGRectMake(40, 150, 200, 100)];
[btn2 setTitle:@"按钮2" forState:UIControlStateNormal];
[btn2 setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
[btn2 addTarget:self action:@selector(btn2TouchDown:) forControlEvents:UIControlEventTouchDown];
[btn2 addTarget:self action:@selector(btn2TouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn2];
- (void) btn1TouchDown: (id) sender
*btn1 = (UIButton *)
[btn1 setHighlighted:YES];
- (void) btn1TouchUpInside: (id) sender
*btn1 = (UIButton *)
[btn1 setHighlighted:NO];
point = CGPointMake(50, 155);
[self sendTap:point];
- (void) btn2TouchDown: (id) sender
NSLog(@"btn2TouchDown\n");
*btn2 = (UIButton *)
[btn2 setHighlighted:YES];
- (void) btn2TouchUpInside: (id) sender
NSLog(@"btn2TouchUpInside\n");
*btn2 = (UIButton *)
[btn2 setHighlighted:NO];
- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
浏览 17799
浏览: 229390 次
来自: 北京
我的怎么不行呀.....
使用时需要注意group_concat函数返回值的最大长度=g ...
可以帮我看下我的代码么?我自己写的sam,也有ac过题的,但是 ...
有1000个?不过还是收藏下。
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'iPhone开发--检查UIWebView上Touch/UITapGestureRecognizer事件的最简单的方法
我有一个程序需要检测UIWebView是否有touch动作,不幸得很,UIWebView上的touchesBegan等事件无法被检测。在网上查了一下,有许多解决方法,比如在UIWebView上再加一个透明的UIView,重置UIWindow的sendEvent或重置UIWebView的hitest方法等等,要么就是方案不太完美,要么就是太过复杂,经过实验我使用的这种方法最为简单(否则我也没有时间写在这里了),当然我只要求检测UIWebView上有touch动作即可。我的方法是使用UITapGestureRecognizer。关键的地方有两点,请看我的代码(我的代码是在一个UIViewController中):
[cpp] UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];&
&& [self.view addGestureRecognizer:singleTap];&
&& singleTap.delegate =&
&& singleTap.cancelsTouchesInView = NO;&
&& [singleTap release];&
&UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
&&& [self.view addGestureRecognizer:singleTap];
&&& singleTap.delegate =
&&& singleTap.cancelsTouchesInView = NO;
&&& [singleTap release];
第三行是第一个关键的地方,就是必须设置UITapGuestureRecognizer的delegate(一般我们直接使用initWithTarget,无需设置其delegate)。
第二个关键的地方是在下列delegate方法return YES。www.2cto.com
[cpp] - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer&
&&& return YES;&
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
&&& return YES;
做到这两点,你的UIWebView就可以响应touch事件了,你可以使用不同的UIGestureRecognizer来满足你不同的要求等。(handleSingleTap方法请自行补上)。
摘自 zcl369369的专栏您需要通过验证再能继续浏览 3秒后开始验证
丨 粤ICP备号-10 丨 新三板上市公司威锋科技(836555)
增值电信业务经营许可证:
Powered by Discuz!
(C) Joyslink Inc. All rights reserved 保留所有权利

我要回帖

更多关于 js模拟输入事件 的文章

 

随机推荐