猿问

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

viewcontroller新建一个scrollview鼠标点击scrollview获取鼠标点击scrollview上的坐标,坐标是相对scrollview的坐标
慕虎7371278
浏览 577回答 2
2回答

温温酱

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}
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答