gpt4 book ai didi

ios - UIButton 单击从静态库触发时不起作用

转载 作者:可可西里 更新时间:2023-11-01 04:43:09 24 4
gpt4 key购买 nike

我们正在尝试使用 webview 从静态库项目触发显示按钮。在将静态库与单 View 应用程序集成时,我们得到了输出设计。但是当我们尝试通过单击按钮尝试操作时,它不起作用。

下面是我们在cocoa touch静态库中使用的代码

UIButton *imageButton = [UIButton buttonWithType:UIButtonTypeCustom];

imageButton.frame = CGRectMake(self.view.frame.size.width-50, 10, 50, 50);

[imageButton setImage:[UIImage imageNamed:@"close.png"] forState:UIControlStateNormal];

imageButton.adjustsImageWhenHighlighted = NO;

// [imageButton addTarget:self action:@selector(close:) forControlEvents:UIControlEventTouchUpInside];

[imageButton addTarget:self action:@selector(hideWebViewBtn:) forControlEvents:UIControlEventTouchUpInside];


-(IBAction)hideWebViewBtn:(id)sender {

NSLog(@"Hide Button clicked");
[self.adView removeFromSuperview];
self.adView = nil;
return;
}

下面是集成运行后在单 View 应用中显示的截图。一旦我点击按钮,它就不会被点击。

enter image description here

最佳答案

试试这个,无论自己的按钮是否触发..

  [self.myButton sendActionsForControlEvents:UIControlEventTouchUpInside];

对我有用

关于ios - UIButton 单击从静态库触发时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45189209/

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