gpt4 book ai didi

iphone - UIButton 操作不使用 UITapGestureRecognizer iphone 应用程序调用?

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:14:33 24 4
gpt4 key购买 nike

我正在使用 UITapGestureRecognizer 和 UIButton 开发 iPhone 应用程序。我在 self.view 中添加了 UITapGestureRecognizer。当我点击 UIButton 时,它不会调用它的 Action ,而只是调用点击手势 Action 。如何解决这个问题?谁能帮忙解决这个问题?

这是我在-ViewDidLoad中的代码,

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom:)];
[self.view addGestureRecognizer:tapRecognizer];
[tapRecognizer release];

UIButton *infoButton1 = [UIButton buttonWithType:UIButtonTypeInfoDark];
infoButton1.frame = CGRectMake(0, 5, 30, 30);
infoButton1.tag = 1;
infoButton1.opaque = YES;
[infoButton1 addTarget:self action:@selector(infoAlert:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
[toolBarView1 addSubview:infoButton1];

-(void) infoAlert:(id) sender
{
NSLog(@"Get Info Alert"); // Here the control not calling..
}


-(void)handleTapFrom:(UITapGestureRecognizer *)recognizer
{
NSLog(@"%@",[NSString stringWithFormat:@"%d", recognizer.view.tag]); // Whenever i touch the button this method only calling.
}

请帮我解决这个问题。提前致谢。

最佳答案

为什么没有人使用 stack overflow 或 Google 的精彩搜索?

这是您的答案:https://stackoverflow.com/a/3348532/312312

在同一个线程中,这似乎是一个更简单的解决方案: https://stackoverflow.com/a/8891030/312312

关于iphone - UIButton 操作不使用 UITapGestureRecognizer iphone 应用程序调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11631827/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com