2014-11-23 78 views
-2

我试图创建一个程序,当我点击屏幕时,警报将弹出.. 因此,我将UIView更改为UIControl,并创建一个IBAction方法当点击屏幕时,然后我发现了一个方法在互联网上打印水龙头位置。调用IBAction方法

这是我的代码:

-(IBAction) Touch:(id)sender{ 
    [self touchesBegan]; 
} 

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch *myTouch = [[touches allObjects] objectAtIndex: 0]; 
    CGPoint currentPos = [myTouch locationInView: self]; 
    NSLog(@"Point in myView: (%f,%f)", currentPos.x, currentPos.y); 
} 

及给予的我一个错误... 怎么办?!?!

+0

其错误它给你? – 2014-11-23 16:24:00

+1

'该怎么做?!?!'告诉我们这个错误究竟是什么将是我能想象的最好的起点。 – nhgrif 2014-11-23 16:24:02

+0

我知道你的错误是什么,删除[self touchesBegan]你是1.调用这个方法没有必要的参数,所以你可能会得到无法识别的选择器发送到实例,第二个uiview自己调用这个方法,你只需要重写它 – 2014-11-23 16:25:08

回答

1

删除您“触摸”的方法[self touchesBegan]

1. calling this method without the necessary parameters, so you are 
probably getting unrecognized selector sent to instance, 
2. the uiview calls this method on its own, you just need to override it