将UIButton置于全屏UIWebView上,以在UIWebView无法加载时关闭它

时间:2011-12-13 23:20:54

标签: iphone ios uiwebview uibutton fullscreen

我的iOS应用中有插页式全屏广告。我无法控制广告的HTML代码。我不希望修改广告网络提供的广告代码。 有时,由于网络问题,广告未加载。 没有办法关闭兴趣。之后应用程序无法使用。

我希望将原生关闭的UIButton放在UIWebView上。 我不使用IB,我必须以编程方式创建这样的按钮。

怎么做?

1 个答案:

答案 0 :(得分:3)

例如,

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self 
           action:@selector(closeAd:)
 forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Close" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[view addSubview:button];

然后在方法

中放入您喜欢的任何代码
-(void)closeAd:(id)sender;
相关问题