为了账号安全,请及时绑定邮箱和手机立即绑定

鼠标点击scrollview 获取点击的坐标

鼠标点击scrollview 获取点击的坐标

慕虎7371278 2019-03-29 10:59:46
viewcontroller新建一个scrollview鼠标点击scrollview获取鼠标点击scrollview上的坐标,坐标是相对scrollview的坐标
查看完整描述

2 回答

?
温温酱

TA贡献1752条经验 获得超4个赞

MyScrollView.h@interfaceMyScrollView:UIScrollView
@endMyScrollView.m@implementationMyScrollView
-(void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event{
UITouch*touch=touches.anyObject;
CGPointtouchLocation=[touchlocationInView:self.window];
NSLog(@"%@",NSStringFromCGPoint(touchLocation));
}MyViewController.m#importMyScrollView.h
-(void)viewDidLoad{
MyScrollView*v=[[MyScrollViewalloc]initWithFrame:CGRectMake(0.0f,0.0f,300.0f,300.0f)];
v.backgroundColor=[UIColorgrayColor];
[self.viewaddSubview:v];
}然后看输出:2012-10-1617:53:11.513Demo[3991:c07]{105,143}
2012-10-1617:53:12.627Demo[3991:c07]{136,310}
2012-10-1617:53:14.519Demo[3991:c07]{277,313}
2012-10-1617:53:16.718Demo[3991:c07]{292,312}
2012-10-1617:53:17.344Demo[3991:c07]{217,198}
2012-10-1617:53:17.776Demo[3991:c07]{152,155}
                            
查看完整回答
反对 回复 2019-03-29
  • 2 回答
  • 0 关注
  • 576 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信