【发布时间】:2026-01-25 03:25:01
【问题描述】:
我们正在尝试使用 webview 从静态库项目中触发显示按钮。在将静态库与单视图应用程序集成时,我们得到了输出设计。但是当我们尝试通过单击按钮尝试操作时,它不起作用。
下面是我们在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;
}
以下是集成并运行后在单视图应用程序中显示的屏幕截图。 一旦我点击按钮,它就不会被点击。
【问题讨论】:
-
试试这个 imageButton.userInteractionEnabled =YES;以及您在哪里添加 imageButton?
-
您是否在按钮顶部添加任何其他视图?
标签: ios objective-c xcode uibutton