【问题标题】:uibutton with touchesBegan带有 touchesBegan 的 uibutton
【发布时间】:2011-05-29 20:53:08
【问题描述】:

我使用touchesBegan:withEvent: 来获取用户在屏幕上的触摸,但是当我触摸按钮时,不会调用此方法。有什么方法可以识别点击了哪个按钮?

编辑:

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{

    UITouch *touch = [[touches allObjects] objectAtIndex:0];
    CGPoint finger = [touch locationInView:self];
    int x = finger.x;
    int y = finger.y;

}

这是touchesBegan:withEvent: 方法。我给每个 UIButton 一个标签号。我确实在界面生成器中连接了 UIButton。

【问题讨论】:

  • 你是如何实现这个的?我们需要更多信息。
  • 如果您发布了一些代码会有所帮助,另外,如果您使用 InterfaceBuilder,您是否记得连接插座?
  • 按钮消耗触摸而不传递它。如果您能说出您想要做什么,我们可以帮助您找到最佳解决方案。
  • 我尝试制作一个可以知道按下了哪个 UIButton 或在按下 UIButton 时获取信息的应用程序,我不想给任何 UIButton 一个方法或所有 UIButtons 的方法

标签: iphone objective-c


【解决方案1】:

请看this 问题。正是您需要的。

【讨论】:

  • thx,当我使用它时,按下 UIButton 时需要发生的方法没有发生的问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多